]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: add realtime parameter for rtc
authorgongwei <gongwei@smartx.com>
Tue, 2 Feb 2021 14:20:46 +0000 (09:20 -0500)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 3 Feb 2021 09:18:04 +0000 (10:18 +0100)
Pass the parameter clock rt to qemu to ensure that the
virtual machine is not synchronized with the host time

Signed-off-by: gongwei <gongwei@smartx.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
docs/formatdomain.rst
docs/schemas/domaincommon.rng
src/conf/domain_conf.c
src/conf/domain_conf.h
src/qemu/qemu_command.c
src/qemu/qemu_validate.c
tests/qemuxml2argvdata/clock-realtime.args [new file with mode: 0644]
tests/qemuxml2argvdata/clock-realtime.xml [new file with mode: 0644]
tests/qemuxml2argvtest.c
tests/qemuxml2xmloutdata/clock-realtime.xml [new symlink]
tests/qemuxml2xmltest.c

index a09868bed5ee66834be5de0634cd7872f9678ef2..3a2fe7fa16d74568cba5f92e856410ad10c2e58a 100644 (file)
@@ -2059,7 +2059,7 @@ Windows, however, expects it to be in so called 'localtime'.
       feature for guests running the Microsoft Windows operating system.
    ``track``
       The ``track`` attribute specifies what the timer tracks, and can be
-      "boot", "guest", or "wall". Only valid for ``name="rtc"`` or
+      "boot", "guest", or "wall", or "realtime". Only valid for ``name="rtc"`` or
       ``name="platform"``.
    ``tickpolicy``
       The ``tickpolicy`` attribute determines what happens when QEMU misses a
index 7bab818bc96cb9c47c2dc857d232f80a01623875..239ae3f3470270ab5f1fa721053f364f020b79ef 100644 (file)
                 <value>boot</value>
                 <value>guest</value>
                 <value>wall</value>
+                <value>realtime</value>
               </choice>
             </attribute>
           </optional>
index 97fa841bff96f691573ff1c779f043aee0814161..69b284192452b6b399c697253330b1611cfafdf2 100644 (file)
@@ -1106,6 +1106,7 @@ VIR_ENUM_IMPL(virDomainTimerTrack,
               "boot",
               "guest",
               "wall",
+              "realtime",
 );
 
 VIR_ENUM_IMPL(virDomainTimerTickpolicy,
index f9ea31d48c66c262f6852dd0b831847343bcb922..dc54f95433b7b7f89f59cefa1f98532dcd78bec9 100644 (file)
@@ -2160,6 +2160,7 @@ typedef enum {
     VIR_DOMAIN_TIMER_TRACK_BOOT = 0,
     VIR_DOMAIN_TIMER_TRACK_GUEST,
     VIR_DOMAIN_TIMER_TRACK_WALL,
+    VIR_DOMAIN_TIMER_TRACK_REALTIME,
 
     VIR_DOMAIN_TIMER_TRACK_LAST
 } virDomainTimerTrackType;
index f613aa02018a5a547f90dd947d8c42b6509d9105..4ed41ed0e404934214da2ef1767a23c1cebfd062 100644 (file)
@@ -5950,6 +5950,9 @@ qemuBuildClockArgStr(virDomainClockDefPtr def)
             case VIR_DOMAIN_TIMER_TRACK_WALL:
                 virBufferAddLit(&buf, ",clock=host");
                 break;
+            case VIR_DOMAIN_TIMER_TRACK_REALTIME:
+                virBufferAddLit(&buf, ",clock=rt");
+                break;
             }
 
             switch (def->timers[i]->tickpolicy) {
index 88f4344df0bc3758ec9ea629e7b2b0dfba508a9b..faadfbf7c8d8ba06ccf7e238e3a2ffc8a9d7046b 100644 (file)
@@ -444,6 +444,7 @@ qemuValidateDomainDefClockTimers(const virDomainDef *def,
             case -1: /* unspecified - use hypervisor default */
             case VIR_DOMAIN_TIMER_TRACK_GUEST:
             case VIR_DOMAIN_TIMER_TRACK_WALL:
+            case VIR_DOMAIN_TIMER_TRACK_REALTIME:
                 break;
             case VIR_DOMAIN_TIMER_TRACK_BOOT:
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
diff --git a/tests/qemuxml2argvdata/clock-realtime.args b/tests/qemuxml2argvdata/clock-realtime.args
new file mode 100644 (file)
index 0000000..bdff45b
--- /dev/null
@@ -0,0 +1,30 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/tmp/lib/domain--1-QEMUGuest1 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \
+XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \
+XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-i386 \
+-name QEMUGuest1 \
+-S \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
+-m 214 \
+-realtime mlock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
+server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc,clock=rt \
+-no-shutdown \
+-no-acpi \
+-usb \
+-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
+-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/clock-realtime.xml b/tests/qemuxml2argvdata/clock-realtime.xml
new file mode 100644 (file)
index 0000000..3ba6b4c
--- /dev/null
@@ -0,0 +1,38 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'>
+    <timer name='rtc' track='realtime'/>
+  </clock>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-i386</emulator>
+    <disk type='block' device='disk'>
+      <driver name='qemu' type='raw'/>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda' bus='ide'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <controller type='usb' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+    </controller>
+    <controller type='ide' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+    </controller>
+    <controller type='pci' index='0' model='pci-root'/>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <memballoon model='virtio'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+    </memballoon>
+  </devices>
+</domain>
index c5d82ac72e9c07eed471294ede297713231adfef..0f4ec4533c6a2faccebd90a3cf53a5c19ac19120 100644 (file)
@@ -1064,6 +1064,7 @@ mymain(void)
     DO_TEST("cpu-host-kvmclock", NONE);
     DO_TEST("kvmclock", QEMU_CAPS_KVM);
     DO_TEST("clock-timer-hyperv-rtc", QEMU_CAPS_KVM);
+    DO_TEST("clock-realtime", NONE);
 
     DO_TEST("cpu-eoi-disabled", NONE);
     DO_TEST("cpu-eoi-enabled", NONE);
diff --git a/tests/qemuxml2xmloutdata/clock-realtime.xml b/tests/qemuxml2xmloutdata/clock-realtime.xml
new file mode 120000 (symlink)
index 0000000..dfa513e
--- /dev/null
@@ -0,0 +1 @@
+../qemuxml2argvdata/clock-realtime.xml
\ No newline at end of file
index 50dd9707893d42bd996c9b7dacf4d6637b235b19..342d70935ff7c9ac656e14cccd56efbb76d73856 100644 (file)
@@ -233,6 +233,7 @@ mymain(void)
     DO_TEST("kvmclock", NONE);
     DO_TEST("clock-timer-hyperv-rtc", NONE);
     DO_TEST_CAPS_ARCH_LATEST("clock-timer-armvtimer", "aarch64");
+    DO_TEST("clock-realtime", NONE);
 
     DO_TEST("cpu-eoi-disabled", NONE);
     DO_TEST("cpu-eoi-enabled", NONE);