Patchwork GlobalProperty in QEMUMachine overwrites explicit command line value

login
register
mail settings
Submitter Crístian Viana
Date May 8, 2012, 9:06 p.m.
Message ID <4FA98AD1.5090806@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/157821/
State New
Headers show

Comments

Crístian Viana - May 8, 2012, 9:06 p.m.
Hi,

I'm trying to change the default value of the parameter "-rtc driftfix=" 
and something's going wrong. This is a GlobalProperty and, currently, it 
is equivalent to setting "-rtc driftfix=none" in the command line. I'm 
appending a new GlobalProperty value to all previous QEMUMachine 
instances (<=pc-1.0):

.driver   = "mc146818rtc",
.property = "lost_tick_policy",
.value    = "discard",

Now when I select older machines, like "-M pc-1.0", it seems that this 
value is _always_ set even if I set another value on the command line. 
So, if I set "-rtc driftfix=slew", it will still use the "none" value 
internally.

The file 0001-Force-driftfix-none-on-previous-machines.patch contains 
the small change I made to set "none" as the default value for that option.

I added this debug statement:

printf("Registering driver %s: %s -> %s\n", prop->driver, 
prop->property, prop->value);

to the function "void qdev_prop_register_global(GlobalProperty *prop)" 
and I got this result:

$ i386-softmmu/qemu-system-i386 -drive 
file=/home/vianac/ISOs/ubuntu-12.04-desktop-i386.iso,media=cdrom -boot d 
-m 1024 -M pc-1.0 -rtc driftfix=slew
Registering driver mc146818rtc: lost_tick_policy -> slew
Registering driver pc-sysfw: rom_only -> 1
Registering driver isa-fdc: check_media_rate -> off
Registering driver virtio-balloon-pci: class -> 0x0500
Registering driver apic: vapic -> off
Registering driver USB: full-path -> no
Registering driver mc146818rtc: lost_tick_policy -> discard

We can see that the lost_tick_policy property is overwritten at the end. 
I know QEmu has "discard" as the default value somewhere in the code, 
but what should we do now? Because there's not only one default value 
anymore; "discard" is the default for older machines and "slew" is for 
newer ones. I thought only by modifying the GlobalProperty list in the 
QEMUMachine struct would be enough. Does that list have the exact values 
to be set for each machine, or those should be the default ones 
(overwritable by the command line, for example)?

Best regards,
Crístian.

Patch

From bc6f181dc3d1a6342f0f26ae185fbf101cedbb02 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cr=C3=ADstian=20Viana?= <vianac@linux.vnet.ibm.com>
Date: Thu, 3 May 2012 17:28:59 -0300
Subject: [PATCH] Force driftfix=none on previous machines
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The current value for the -rtc driftfix option is 'none'. This patch
makes sure that the old machines configuration will work the same way
even after that option changes its default value.

Signed-off-by: Crístian Viana <vianac@linux.vnet.ibm.com>
---
 hw/pc_piix.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index 6a75718..35633f0 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -381,6 +381,10 @@  static QEMUMachine pc_machine_v1_1 = {
             .driver   = "USB",\
             .property = "full-path",\
             .value    = "no",\
+        },{\
+            .driver   = "mc146818rtc",\
+            .property = "lost_tick_policy",\
+            .value    = "discard",\
         }
 
 static QEMUMachine pc_machine_v1_0 = {
-- 
1.7.9.5