Bug 1102411

Summary: qemu guest-set-time: RTC timer interrupt reinjection vs guest-set-time
Product: Red Hat Enterprise Linux 7 Reporter: Marcelo Tosatti <mtosatti>
Component: qemu-kvm-rhevAssignee: Marcelo Tosatti <mtosatti>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.1CC: juzhang, knoel, michen, mprivozn, mrezanin, mtosatti, rbalakri, scui, sluo, virt-maint, xfu
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: qemu 2.1.0 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-03-05 09:46:28 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1049040, 1110708    
Attachments:
Description Flags
log_level.1_libvirtd.log none

Description Marcelo Tosatti 2014-05-28 23:23:51 UTC
RTC timer interrupt reinjection _and_ guest-set-time 
 are not aware of each other, therefore
should verify they don't cause Windows time to drift
(should reset RTC timer interrupt reinjection in case
guest-set-time is operational).

Comment 2 Marcelo Tosatti 2014-08-22 22:43:18 UTC
commit f2ae8abf1fa003e7ec6ee22cc3871924422a01d0 is part of qemu 2.1.0, marking as MODIFIED.

Comment 6 Sibiao Luo 2014-10-08 05:52:56 UTC
Tried this issue with the instruction of comment #5 on qemu-kvm-rhev-2.1.2-1.el7.x86_64.
host info:
# uname -r && rpm -q qemu-kvm-rhev && rpm -q seabios
3.10.0-171.el7.x86_64
qemu-kvm-rhev-2.1.2-1.el7.x86_64
seabios-1.7.5-5.el7.x86_64
guest info:
windows 2012 R2
qemu-guest-agent-2.1.0-3
virtio-win-prewhql-0.1-93 (virtio-serial)

qemu-kvm command line:
# /usr/libexec/qemu-kvm -M pc -S -cpu SandyBridge -enable-kvm -m 2048 -smp 4,sockets=2,cores=2,threads=1 -no-kvm-pit-reinjection -usb -device usb-tablet,id=input0 -name sluo -uuid 990ea161-6b67-47b2-b803-19fb01d30d30 -rtc base=localtime,clock=host,driftfix=slew -drive file=/home/win2012r2-64.qcow2,if=none,id=drive-system-disk,format=qcow2,cache=none,aio=native -device ide-hd,drive=drive-system-disk,id=system-disk,bus=ide.0,unit=0,bootindex=1 -netdev tap,id=hostnet0,vhost=on,script=/etc/qemu-ifup -device e1000,netdev=hostnet0,id=e1000-net-pci0,mac=00:01:02:B6:40:21,bus=pci.0,addr=0x5 -device virtio-balloon-pci,id=ballooning,bus=pci.0,addr=0x6 -global PIIX4_PM.disable_s3=0 -global PIIX4_PM.disable_s4=0 -k en-us -boot menu=on -qmp tcp:0:4444,server,nowait -serial unix:/tmp/ttyS0,server,nowait -vnc :1 -spice disable-ticketing,port=5931 -monitor stdio -chardev socket,path=/tmp/qga.sock,server,nowait,id=qga0 -device virtio-serial-pci,id=virtio-serial0,max_ports=16,vectors=0,bus=pci.0,addr=0x3 -device virtserialport,chardev=qga0,name=org.qemu.guest_agent.0

Steps:
0).Install guest agent in guest and check the time both guest and host at Wed 08 Oct 2014 01:38:13 PM.
# nc -U /tmp/qga.sock
{"execute":"guest-sync", "arguments":{"id":1234}}
{"return": 1234}
{"execute":"guest-ping"}
{"return": {}}

1).Stop guest for 5 minutes (via QMP).
{"execute":"query-status"}
{"return": {"status": "running", "singlestep": false, "running": true}}
{"execute":"stop"}
{"timestamp": {"seconds": 1412746694, "microseconds": 239020}, "event": "STOP"}
{"return": {}}
{"execute":"query-status"}
{"return": {"status": "paused", "singlestep": false, "running": false}}

2).Resume guest.
{"execute":"cont"}
{"timestamp": {"seconds": 1412746994, "microseconds": 921638}, "event": "RESUME"}
{"return": {}}

3).Wait 30 seconds.

4).Confirm guest time matches host time.

Results:
after step 4, guest time cann't recover which match the host time.
## host: Wed 08 Oct 2014 01:43:14 PM CST
##guest: it starts from Wed 08 Oct 2014 01:38:13 PM which cann't recover to match the host time, guest was slower than host for 5 minutes.

Base on above, this issue did not fix correctly, re-assign it to fix.

Best Regards,
sluo

Comment 7 Sibiao Luo 2014-10-08 06:17:09 UTC
(In reply to Sibiao Luo from comment #6)
> Tried this issue with the instruction of comment #5 on
> qemu-kvm-rhev-2.1.2-1.el7.x86_64.
> host info:
> # uname -r && rpm -q qemu-kvm-rhev && rpm -q seabios
> 3.10.0-171.el7.x86_64
> qemu-kvm-rhev-2.1.2-1.el7.x86_64
> seabios-1.7.5-5.el7.x86_64
> guest info:
> windows 2012 R2
> qemu-guest-agent-2.1.0-3
paste the wrong qemu-ga-win version, it was qemu-ga-win-7.0-9 x86 MSI indeed.
> virtio-win-prewhql-0.1-93 (virtio-serial)
> 
Best Regards,
sluo

Comment 8 Marcelo Tosatti 2014-10-08 17:34:35 UTC
(In reply to Sibiao Luo from comment #6)
> Tried this issue with the instruction of comment #5 on
> qemu-kvm-rhev-2.1.2-1.el7.x86_64.
> host info:
> # uname -r && rpm -q qemu-kvm-rhev && rpm -q seabios
> 3.10.0-171.el7.x86_64
> qemu-kvm-rhev-2.1.2-1.el7.x86_64
> seabios-1.7.5-5.el7.x86_64
> guest info:
> windows 2012 R2
> qemu-guest-agent-2.1.0-3
> virtio-win-prewhql-0.1-93 (virtio-serial)
> 
> qemu-kvm command line:
> # /usr/libexec/qemu-kvm -M pc -S -cpu SandyBridge -enable-kvm -m 2048 -smp
> 4,sockets=2,cores=2,threads=1 -no-kvm-pit-reinjection -usb -device
> usb-tablet,id=input0 -name sluo -uuid 990ea161-6b67-47b2-b803-19fb01d30d30
> -rtc base=localtime,clock=host,driftfix=slew -drive
> file=/home/win2012r2-64.qcow2,if=none,id=drive-system-disk,format=qcow2,
> cache=none,aio=native -device
> ide-hd,drive=drive-system-disk,id=system-disk,bus=ide.0,unit=0,bootindex=1
> -netdev tap,id=hostnet0,vhost=on,script=/etc/qemu-ifup -device
> e1000,netdev=hostnet0,id=e1000-net-pci0,mac=00:01:02:B6:40:21,bus=pci.0,
> addr=0x5 -device virtio-balloon-pci,id=ballooning,bus=pci.0,addr=0x6 -global
> PIIX4_PM.disable_s3=0 -global PIIX4_PM.disable_s4=0 -k en-us -boot menu=on
> -qmp tcp:0:4444,server,nowait -serial unix:/tmp/ttyS0,server,nowait -vnc :1
> -spice disable-ticketing,port=5931 -monitor stdio -chardev
> socket,path=/tmp/qga.sock,server,nowait,id=qga0 -device
> virtio-serial-pci,id=virtio-serial0,max_ports=16,vectors=0,bus=pci.0,
> addr=0x3 -device virtserialport,chardev=qga0,name=org.qemu.guest_agent.0
> 
> Steps:
> 0).Install guest agent in guest and check the time both guest and host at
> Wed 08 Oct 2014 01:38:13 PM.
> # nc -U /tmp/qga.sock
> {"execute":"guest-sync", "arguments":{"id":1234}}
> {"return": 1234}
> {"execute":"guest-ping"}
> {"return": {}}
> 
> 1).Stop guest for 5 minutes (via QMP).
> {"execute":"query-status"}
> {"return": {"status": "running", "singlestep": false, "running": true}}
> {"execute":"stop"}
> {"timestamp": {"seconds": 1412746694, "microseconds": 239020}, "event":
> "STOP"}
> {"return": {}}
> {"execute":"query-status"}
> {"return": {"status": "paused", "singlestep": false, "running": false}}
> 
> 2).Resume guest.
> {"execute":"cont"}
> {"timestamp": {"seconds": 1412746994, "microseconds": 921638}, "event":
> "RESUME"}
> {"return": {}}
> 
> 3).Wait 30 seconds.
> 
> 4).Confirm guest time matches host time.
> 
> Results:
> after step 4, guest time cann't recover which match the host time.
> ## host: Wed 08 Oct 2014 01:43:14 PM CST
> ##guest: it starts from Wed 08 Oct 2014 01:38:13 PM which cann't recover to
> match the host time, guest was slower than host for 5 minutes.
> 
> Base on above, this issue did not fix correctly, re-assign it to fix.
> 
> Best Regards,
> sluo

Sibiao,

Stopping and resuming the guest must be done via libvirt, not via QMP.

Comment 9 Sibiao Luo 2014-10-11 03:26:13 UTC
(In reply to Marcelo Tosatti from comment #8)
> > Steps:
> > 0).Install guest agent in guest and check the time both guest and host at
> > Wed 08 Oct 2014 01:38:13 PM.
> > # nc -U /tmp/qga.sock
> > {"execute":"guest-sync", "arguments":{"id":1234}}
> > {"return": 1234}
> > {"execute":"guest-ping"}
> > {"return": {}}
> > 
> > 1).Stop guest for 5 minutes (via QMP).
> > {"execute":"query-status"}
> > {"return": {"status": "running", "singlestep": false, "running": true}}
> > {"execute":"stop"}
> > {"timestamp": {"seconds": 1412746694, "microseconds": 239020}, "event":
> > "STOP"}
> > {"return": {}}
> > {"execute":"query-status"}
> > {"return": {"status": "paused", "singlestep": false, "running": false}}
> > 
> > 2).Resume guest.
> > {"execute":"cont"}
> > {"timestamp": {"seconds": 1412746994, "microseconds": 921638}, "event":
> > "RESUME"}
> > {"return": {}}
> > 
> > 3).Wait 30 seconds.
> > 
> > 4).Confirm guest time matches host time.
> > 
> > Results:
> > after step 4, guest time cann't recover which match the host time.
> > ## host: Wed 08 Oct 2014 01:43:14 PM CST
> > ##guest: it starts from Wed 08 Oct 2014 01:38:13 PM which cann't recover to
> > match the host time, guest was slower than host for 5 minutes.
> > 
> > Base on above, this issue did not fix correctly, re-assign it to fix.
> > 
> > Best Regards,
> > sluo
> 
> Sibiao,
> 
> Stopping and resuming the guest must be done via libvirt, not via QMP.
But I started the KVM guest via qemu-kvm command line directly and the libvirt should also call for QMP API, how can i stoping/resuming VM via libvirt/virsh if i use the qemu-kvm, should i need to test this issue using XML via virsh directly ? Thanks in advance.

Best Regards,
sluo

Comment 10 Marcelo Tosatti 2014-10-13 08:11:39 UTC
(In reply to Sibiao Luo from comment #9)
> (In reply to Marcelo Tosatti from comment #8)
> > > Steps:
> > > 0).Install guest agent in guest and check the time both guest and host at
> > > Wed 08 Oct 2014 01:38:13 PM.
> > > # nc -U /tmp/qga.sock
> > > {"execute":"guest-sync", "arguments":{"id":1234}}
> > > {"return": 1234}
> > > {"execute":"guest-ping"}
> > > {"return": {}}
> > > 
> > > 1).Stop guest for 5 minutes (via QMP).
> > > {"execute":"query-status"}
> > > {"return": {"status": "running", "singlestep": false, "running": true}}
> > > {"execute":"stop"}
> > > {"timestamp": {"seconds": 1412746694, "microseconds": 239020}, "event":
> > > "STOP"}
> > > {"return": {}}
> > > {"execute":"query-status"}
> > > {"return": {"status": "paused", "singlestep": false, "running": false}}
> > > 
> > > 2).Resume guest.
> > > {"execute":"cont"}
> > > {"timestamp": {"seconds": 1412746994, "microseconds": 921638}, "event":
> > > "RESUME"}
> > > {"return": {}}
> > > 
> > > 3).Wait 30 seconds.
> > > 
> > > 4).Confirm guest time matches host time.
> > > 
> > > Results:
> > > after step 4, guest time cann't recover which match the host time.
> > > ## host: Wed 08 Oct 2014 01:43:14 PM CST
> > > ##guest: it starts from Wed 08 Oct 2014 01:38:13 PM which cann't recover to
> > > match the host time, guest was slower than host for 5 minutes.
> > > 
> > > Base on above, this issue did not fix correctly, re-assign it to fix.
> > > 
> > > Best Regards,
> > > sluo
> > 
> > Sibiao,
> > 
> > Stopping and resuming the guest must be done via libvirt, not via QMP.
> But I started the KVM guest via qemu-kvm command line directly and the
> libvirt should also call for QMP API, how can i stoping/resuming VM via
> libvirt/virsh if i use the qemu-kvm, should i need to test this issue using
> XML via virsh directly ? Thanks in advance.

Yes you should use virsh directly.

Comment 11 Sibiao Luo 2014-10-15 05:15:08 UTC
(In reply to Marcelo Tosatti from comment #10)
> (In reply to Sibiao Luo from comment #9)
> > (In reply to Marcelo Tosatti from comment #8)
> > > > Steps:
> > > > 0).Install guest agent in guest and check the time both guest and host at
> > > > Wed 08 Oct 2014 01:38:13 PM.
> > > > # nc -U /tmp/qga.sock
> > > > {"execute":"guest-sync", "arguments":{"id":1234}}
> > > > {"return": 1234}
> > > > {"execute":"guest-ping"}
> > > > {"return": {}}
> > > > 
> > > > 1).Stop guest for 5 minutes (via QMP).
> > > > {"execute":"query-status"}
> > > > {"return": {"status": "running", "singlestep": false, "running": true}}
> > > > {"execute":"stop"}
> > > > {"timestamp": {"seconds": 1412746694, "microseconds": 239020}, "event":
> > > > "STOP"}
> > > > {"return": {}}
> > > > {"execute":"query-status"}
> > > > {"return": {"status": "paused", "singlestep": false, "running": false}}
> > > > 
> > > > 2).Resume guest.
> > > > {"execute":"cont"}
> > > > {"timestamp": {"seconds": 1412746994, "microseconds": 921638}, "event":
> > > > "RESUME"}
> > > > {"return": {}}
> > > > 
> > > > 3).Wait 30 seconds.
> > > > 
> > > > 4).Confirm guest time matches host time.
> > > > 
> > > > Results:
> > > > after step 4, guest time cann't recover which match the host time.
> > > > ## host: Wed 08 Oct 2014 01:43:14 PM CST
> > > > ##guest: it starts from Wed 08 Oct 2014 01:38:13 PM which cann't recover to
> > > > match the host time, guest was slower than host for 5 minutes.
> > > > 
> > > > Base on above, this issue did not fix correctly, re-assign it to fix.
> > > > 
> > > > Best Regards,
> > > > sluo
> > > 
> > > Sibiao,
> > > 
> > > Stopping and resuming the guest must be done via libvirt, not via QMP.
> > But I started the KVM guest via qemu-kvm command line directly and the
> > libvirt should also call for QMP API, how can i stoping/resuming VM via
> > libvirt/virsh if i use the qemu-kvm, should i need to test this issue using
> > XML via virsh directly ? Thanks in advance.
> 
> Yes you should use virsh directly.
Still hit this issue with virsh directly.

host info:
# uname -r && rpm -q qemu-kvm-rhev
3.10.0-183.el7.x86_64
qemu-kvm-rhev-2.1.2-1.el7.x86_64
guest info:
windows 2012 R2

Steps:
1.append the S3/S4 supported in the xml.
  <pm>
    <suspend-to-disk enabled='yes'/>
    <suspend-to-mem enabled='yes'/>
  </pm>
2.launch the KVM guest via libvirt.
# virsh create test.xml 
Domain test created from test.xml

3.record the guest time after VM boot up and stop guest for 5 minutes (via libvirt).
Wed Oct 15 12:54:09 EDT 2014
# virsh suspend test
Domain test suspended

4.resume the VM after 5 minutes and wait fo 30 seconds to verify the guest time.
# virsh resume test
Domain test resumed

Results:
after step 4, It still began from Wed Oct 15 12:54:09 EDT 2014, guest time cann't recover which match the host time which cann't recover to match the host time, guest was slower than host for 5 minutes.

Comment 12 Marcelo Tosatti 2014-10-15 07:49:36 UTC
(In reply to Sibiao Luo from comment #11)
> (In reply to Marcelo Tosatti from comment #10)
> > (In reply to Sibiao Luo from comment #9)
> > > (In reply to Marcelo Tosatti from comment #8)
> > > > > Steps:
> > > > > 0).Install guest agent in guest and check the time both guest and host at
> > > > > Wed 08 Oct 2014 01:38:13 PM.
> > > > > # nc -U /tmp/qga.sock
> > > > > {"execute":"guest-sync", "arguments":{"id":1234}}
> > > > > {"return": 1234}
> > > > > {"execute":"guest-ping"}
> > > > > {"return": {}}
> > > > > 
> > > > > 1).Stop guest for 5 minutes (via QMP).
> > > > > {"execute":"query-status"}
> > > > > {"return": {"status": "running", "singlestep": false, "running": true}}
> > > > > {"execute":"stop"}
> > > > > {"timestamp": {"seconds": 1412746694, "microseconds": 239020}, "event":
> > > > > "STOP"}
> > > > > {"return": {}}
> > > > > {"execute":"query-status"}
> > > > > {"return": {"status": "paused", "singlestep": false, "running": false}}
> > > > > 
> > > > > 2).Resume guest.
> > > > > {"execute":"cont"}
> > > > > {"timestamp": {"seconds": 1412746994, "microseconds": 921638}, "event":
> > > > > "RESUME"}
> > > > > {"return": {}}
> > > > > 
> > > > > 3).Wait 30 seconds.
> > > > > 
> > > > > 4).Confirm guest time matches host time.
> > > > > 
> > > > > Results:
> > > > > after step 4, guest time cann't recover which match the host time.
> > > > > ## host: Wed 08 Oct 2014 01:43:14 PM CST
> > > > > ##guest: it starts from Wed 08 Oct 2014 01:38:13 PM which cann't recover to
> > > > > match the host time, guest was slower than host for 5 minutes.
> > > > > 
> > > > > Base on above, this issue did not fix correctly, re-assign it to fix.
> > > > > 
> > > > > Best Regards,
> > > > > sluo
> > > > 
> > > > Sibiao,
> > > > 
> > > > Stopping and resuming the guest must be done via libvirt, not via QMP.
> > > But I started the KVM guest via qemu-kvm command line directly and the
> > > libvirt should also call for QMP API, how can i stoping/resuming VM via
> > > libvirt/virsh if i use the qemu-kvm, should i need to test this issue using
> > > XML via virsh directly ? Thanks in advance.
> > 
> > Yes you should use virsh directly.
> Still hit this issue with virsh directly.
> 
> host info:
> # uname -r && rpm -q qemu-kvm-rhev
> 3.10.0-183.el7.x86_64
> qemu-kvm-rhev-2.1.2-1.el7.x86_64
> guest info:
> windows 2012 R2
> 
> Steps:
> 1.append the S3/S4 supported in the xml.
>   <pm>
>     <suspend-to-disk enabled='yes'/>
>     <suspend-to-mem enabled='yes'/>
>   </pm>
> 2.launch the KVM guest via libvirt.
> # virsh create test.xml 
> Domain test created from test.xml
> 
> 3.record the guest time after VM boot up and stop guest for 5 minutes (via
> libvirt).
> Wed Oct 15 12:54:09 EDT 2014
> # virsh suspend test
> Domain test suspended
> 
> 4.resume the VM after 5 minutes and wait fo 30 seconds to verify the guest
> time.
> # virsh resume test
> Domain test resumed
> 
> Results:
> after step 4, It still began from Wed Oct 15 12:54:09 EDT 2014, guest time
> cann't recover which match the host time which cann't recover to match the
> host time, guest was slower than host for 5 minutes.


Sibiao,

Two questions:

Is the guest agent configured in the guest? Can you please provide libvirt logs?

How do you retrieve guest time?>

Comment 13 Sibiao Luo 2014-10-15 09:52:26 UTC
(In reply to Marcelo Tosatti from comment #12)
> (In reply to Sibiao Luo from comment #11)
> > (In reply to Marcelo Tosatti from comment #10)
> > > (In reply to Sibiao Luo from comment #9)
> > > > (In reply to Marcelo Tosatti from comment #8)
> > > > > Stopping and resuming the guest must be done via libvirt, not via QMP.
> > > > But I started the KVM guest via qemu-kvm command line directly and the
> > > > libvirt should also call for QMP API, how can i stoping/resuming VM via
> > > > libvirt/virsh if i use the qemu-kvm, should i need to test this issue using
> > > > XML via virsh directly ? Thanks in advance.
> > > 
> > > Yes you should use virsh directly.
> > Still hit this issue with virsh directly.
> > 
> > host info:
> > # uname -r && rpm -q qemu-kvm-rhev
> > 3.10.0-183.el7.x86_64
> > qemu-kvm-rhev-2.1.2-1.el7.x86_64
> > guest info:
> > windows 2012 R2
> > 
> > Steps:
> > 1.append the S3/S4 supported in the xml.
> >   <pm>
> >     <suspend-to-disk enabled='yes'/>
> >     <suspend-to-mem enabled='yes'/>
> >   </pm>
> > 2.launch the KVM guest via libvirt.
> > # virsh create test.xml 
> > Domain test created from test.xml
> > 
> > 3.record the guest time after VM boot up and stop guest for 5 minutes (via
> > libvirt).
> > Wed Oct 15 12:54:09 EDT 2014
> > # virsh suspend test
> > Domain test suspended
> > 
> > 4.resume the VM after 5 minutes and wait fo 30 seconds to verify the guest
> > time.
> > # virsh resume test
> > Domain test resumed
> > 
> > Results:
> > after step 4, It still began from Wed Oct 15 12:54:09 EDT 2014, guest time
> > cann't recover which match the host time which cann't recover to match the
> > host time, guest was slower than host for 5 minutes.
> 
> 
> Sibiao,
> 
> Two questions:
> 
> Is the guest agent configured in the guest? Can you please provide libvirt
> logs?
> 
Hmm....I made a mistake about your meaning influenced by my using the qemu-kvm command line all the time. Your stop/resume is about ACPI(S3), but i thought it was stop/cont in our HMP/QMP monitor command.

> How do you retrieve guest time?>
Login guest to click the 'Date and Time' to see it.

Retried it with the following commands which guest can recover to match the host time after wait for more than 10 minutes.

# virsh qemu-agent-command --domain test '{"execute":"guest-suspend-ram", "arguments": { "id": 123456 } }'
# virsh qemu-agent-command --domain test '{"execute":"system_wakeup" }' or wakeup via pressing any keyboard.

XML configure file:
  <pm>
    <suspend-to-disk enabled='yes'/>
    <suspend-to-mem enabled='yes'/>
  </pm>
...
    <channel type='unix'>
      <source mode='bind' path='/var/lib/libvirt/qemu/test.agent'/>
      <target type='virtio' name='org.qemu.guest_agent.0'/>
      <address type='virtio-serial' controller='0' bus='0' port='1'/>
    </channel>
    <input type='mouse' bus='ps2'/>
    <graphics type='spice' port='5931' autoport='yes' listen='127.0.0.1'>
      <listen type='address' address='127.0.0.1'/>
    </graphics>
    <video>
      <model type='qxl' vram='9216' heads='1'/>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
...

# ps axu | grep qemu-kvm
qemu      5432 16.0 55.9 2741248 2168020 ?     Sl   05:04   7:20 /usr/libexec/qemu-kvm -name test -S -machine pc-i440fx-rhel7.1.0,accel=kvm,usb=off -m 2048 -realtime mlock=off -smp 2,sockets=2,cores=1,threads=1 -uuid d1a23b70-ab11-47a1-9ad7-0de528202542 -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/test.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -global PIIX4_PM.disable_s3=0 -global PIIX4_PM.disable_s4=0 -boot strict=on -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x5 -drive file=/home/win7-64.qcow2,if=none,id=drive-ide0-0-0,format=qcow2,cache=none -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 -netdev tap,fd=23,id=hostnet0 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=0a:01:38:b6:40:24,bus=pci.0,addr=0x3 -chardev socket,id=charchannel0,path=/var/lib/libvirt/qemu/test.agent,server,nowait -device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=org.qemu.guest_agent.0 -spice port=5900,addr=127.0.0.1,disable-ticketing,seamless-migration=on -device qxl-vga,id=video0,ram_size=67108864,vram_size=9437184,bus=pci.0,addr=0x2 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 -msg timestamp=on

host info:
# uname -r && rpm -q qemu-kvm-rhev
3.10.0-183.el7.x86_64
qemu-kvm-rhev-2.1.2-1.el7.x86_64
guest info:
windows 2012 R2

Base above, this issue has been fixed correctly.

Best Regards,
sluo

Comment 14 Sibiao Luo 2014-10-15 09:59:29 UTC
Append a little issue about the virsh ACPI, i meet a error when do S3, but it did not effect for me to verify this bug. If i use qemu-kvm virt-agent directory which did not meet this error. How about this error, should we need to file a new bug against libvirt ? Thanks for your checking in advance.

# virsh qemu-agent-command --domain test '{"execute":"guest-suspend-ram", "arguments": { "id": 123456 } }'
error: Guest agent is not responding: Guest agent not available for now

# virsh list
 Id    Name                           State
----------------------------------------------------
 12    test                           pmsuspended

Best Regards,
sluo

Comment 15 Marcelo Tosatti 2014-10-15 10:32:05 UTC
(In reply to Sibiao Luo from comment #13)
> Hmm....I made a mistake about your meaning influenced by my using the
> qemu-kvm command line all the time. Your stop/resume is about ACPI(S3), but
> i thought it was stop/cont in our HMP/QMP monitor command.
> 
> > How do you retrieve guest time?>
> Login guest to click the 'Date and Time' to see it.
> 
> Retried it with the following commands which guest can recover to match the
> host time after wait for more than 10 minutes.
> 
> # virsh qemu-agent-command --domain test '{"execute":"guest-suspend-ram",
> "arguments": { "id": 123456 } }'
> # virsh qemu-agent-command --domain test '{"execute":"system_wakeup" }' or
> wakeup via pressing any keyboard.

No, stop/resume is about stop/cont! That is:

virsh suspend 
virsh resume

Please attach the libvirt logs for that case.

Comment 16 Sibiao Luo 2014-10-15 11:15:00 UTC
Created attachment 947188 [details]
log_level.1_libvirtd.log

Comment 17 Sibiao Luo 2014-10-15 11:19:55 UTC
(In reply to Marcelo Tosatti from comment #15)
> (In reply to Sibiao Luo from comment #13)
> > Hmm....I made a mistake about your meaning influenced by my using the
> > qemu-kvm command line all the time. Your stop/resume is about ACPI(S3), but
> > i thought it was stop/cont in our HMP/QMP monitor command.
> > 
> > > How do you retrieve guest time?>
> > Login guest to click the 'Date and Time' to see it.
> > 
> > Retried it with the following commands which guest can recover to match the
> > host time after wait for more than 10 minutes.
> > 
> > # virsh qemu-agent-command --domain test '{"execute":"guest-suspend-ram",
> > "arguments": { "id": 123456 } }'
> > # virsh qemu-agent-command --domain test '{"execute":"system_wakeup" }' or
> > wakeup via pressing any keyboard.
> 
> No, stop/resume is about stop/cont! That is:
> 
> virsh suspend 
> virsh resume
> 
> Please attach the libvirt logs for that case.

Thanks, please refer to my libvirt log in attachment 947188 [details] which log_level is 1.

Actions:
set log_level = 1 in /etc/libvirt/libvirtd.conf and restart libvirtd service.
# echo > /var/log/libvirt/libvirtd.log
# virsh create test.xml 
Domain test created from test.xml

# virsh list
 Id    Name                           State
----------------------------------------------------
 2     test                           running

# virsh suspend test
Domain test suspended

# date
Wed Oct 15 17:00:18 CST 2014
# 
# date
Wed Oct 15 17:06:53 CST 2014
# virsh resume test
Domain test resumed

# virsh destroy test
Domain test destroyed

# virsh list
 Id    Name                           State
----------------------------------------------------

Comment 18 Marcelo Tosatti 2014-10-20 10:42:33 UTC
(In reply to Sibiao Luo from comment #16)
> Created attachment 947188 [details]
> log_level.1_libvirtd.log

Michal,

Any idea why libvirt is not executing guest-set-time ?

Comment 19 Michal Privoznik 2014-10-20 11:45:55 UTC
(In reply to Marcelo Tosatti from comment #18)
> (In reply to Sibiao Luo from comment #16)
> > Created attachment 947188 [details]
> > log_level.1_libvirtd.log
> 
> Michal,
> 
> Any idea why libvirt is not executing guest-set-time ?

Yeah. We've split the the guest-set-time into a separate API: virsh domtime. The idea is, that mgm application should decide whether time should be synced on resume or not. So the test suite should be:

1) virsh suspend test
2) wait
3) virsh resume test && virsh domtime --sync
4) check the domain time

Comment 20 Marcelo Tosatti 2014-10-22 19:39:09 UTC
(In reply to Michal Privoznik from comment #19)
> (In reply to Marcelo Tosatti from comment #18)
> > (In reply to Sibiao Luo from comment #16)
> > > Created attachment 947188 [details]
> > > log_level.1_libvirtd.log
> > 
> > Michal,
> > 
> > Any idea why libvirt is not executing guest-set-time ?
> 
> Yeah. We've split the the guest-set-time into a separate API: virsh domtime.
> The idea is, that mgm application should decide whether time should be
> synced on resume or not. So the test suite should be:
> 
> 1) virsh suspend test
> 2) wait
> 3) virsh resume test && virsh domtime --sync
> 4) check the domain time

Sibiao,

Can you execute the test case mentioned by Michal ?

Also, need to get Windows XP tested as well.

Comment 21 Sibiao Luo 2014-10-23 06:09:48 UTC
(In reply to Marcelo Tosatti from comment #20)
> (In reply to Michal Privoznik from comment #19)
> > (In reply to Marcelo Tosatti from comment #18)
> > > (In reply to Sibiao Luo from comment #16)
> > > > Created attachment 947188 [details]
> > > > log_level.1_libvirtd.log
> > > 
> > > Michal,
> > > 
> > > Any idea why libvirt is not executing guest-set-time ?
> > 
> > Yeah. We've split the the guest-set-time into a separate API: virsh domtime.
> > The idea is, that mgm application should decide whether time should be
> > synced on resume or not. So the test suite should be:
> > 
> > 1) virsh suspend test
> > 2) wait
> > 3) virsh resume test && virsh domtime --sync
> > 4) check the domain time
> 
> Sibiao,
> 
> Can you execute the test case mentioned by Michal ?
OK
> Also, need to get Windows XP tested as well.
Yes, i will try it.

But execute 'virsh domtime --sync' will fail with 'unknown QEMU command error'. Does it a new issue, should we need to file new bug for it.
######for windows guest:
# virsh resume test && virsh domtime test --sync
Domain test resumed

error: internal error: unable to execute QEMU agent command 'guest-set-time': unknown QEMU command error
######for rhel guest:
# virsh domtime test --sync
error: internal error: unable to execute QEMU agent command 'guest-set-time': Invalid parameter type for 'time', expected: integer

BTW, I can using 'virsh resume test && virsh test domtime --now' to synchronize the guest time which guest can recover to match the host time after wait for more than 10 minutes.

host info:
# uname -r && rpm -q qemu-kvm-rhev
3.10.0-183.el7.x86_64
qemu-kvm-rhev-2.1.2-4.el7.x86_64
guest info:
qemu-ga-win-7.0-9
window 7 64bit guest

Best Regards,
sluo

Comment 22 Marcelo Tosatti 2014-10-23 12:14:06 UTC
(In reply to Sibiao Luo from comment #21)
> (In reply to Marcelo Tosatti from comment #20)
> > (In reply to Michal Privoznik from comment #19)
> > > (In reply to Marcelo Tosatti from comment #18)
> > > > (In reply to Sibiao Luo from comment #16)
> > > > > Created attachment 947188 [details]
> > > > > log_level.1_libvirtd.log
> > > > 
> > > > Michal,
> > > > 
> > > > Any idea why libvirt is not executing guest-set-time ?
> > > 
> > > Yeah. We've split the the guest-set-time into a separate API: virsh domtime.
> > > The idea is, that mgm application should decide whether time should be
> > > synced on resume or not. So the test suite should be:
> > > 
> > > 1) virsh suspend test
> > > 2) wait
> > > 3) virsh resume test && virsh domtime --sync
> > > 4) check the domain time
> > 
> > Sibiao,
> > 
> > Can you execute the test case mentioned by Michal ?
> OK
> > Also, need to get Windows XP tested as well.
> Yes, i will try it.
> 
> But execute 'virsh domtime --sync' will fail with 'unknown QEMU command
> error'. Does it a new issue, should we need to file new bug for it.
> ######for windows guest:
> # virsh resume test && virsh domtime test --sync
> Domain test resumed> 
> error: internal error: unable to execute QEMU agent command
> 'guest-set-time': unknown QEMU command error

Please open a new bug and attach libvirt logs.

> ######for rhel guest:
> # virsh domtime test --sync
> error: internal error: unable to execute QEMU agent command
> 'guest-set-time': Invalid parameter type for 'time', expected: integer

Please attach this issue to the new bug as well.

> BTW, I can using 'virsh resume test && virsh test domtime --now' to
> synchronize the guest time which guest can recover to match the host time
> after wait for more than 10 minutes.

OK, does it work with Windows?
 
> host info:
> # uname -r && rpm -q qemu-kvm-rhev
> 3.10.0-183.el7.x86_64
> qemu-kvm-rhev-2.1.2-4.el7.x86_64
> guest info:
> qemu-ga-win-7.0-9
> window 7 64bit guest
> 
> Best Regards,
> sluo

Comment 23 Marcelo Tosatti 2014-10-23 13:13:27 UTC
(In reply to Sibiao Luo from comment #21)
> BTW, I can using 'virsh resume test && virsh test domtime --now' to
> synchronize the guest time which guest can recover to match the host time
> after wait for more than 10 minutes.
> 
> host info:
> # uname -r && rpm -q qemu-kvm-rhev
> 3.10.0-183.el7.x86_64
> qemu-kvm-rhev-2.1.2-4.el7.x86_64
> guest info:
> qemu-ga-win-7.0-9
> window 7 64bit guest
> 
> Best Regards,
> sluo

Sibiao, 

What is sufficient to test this bug is the following:

* Windows XP guest with qemu guest agent installed.

* virsh resume test && virsh domtime test --now

Under those conditions, Windows XP guest time should be correct after
"virsh domtime" command.

Comment 24 Sibiao Luo 2014-10-24 04:33:19 UTC
(In reply to Marcelo Tosatti from comment #22)
> > But execute 'virsh domtime --sync' will fail with 'unknown QEMU command
> > error'. Does it a new issue, should we need to file new bug for it.
> > ######for windows guest:
> > # virsh resume test && virsh domtime test --sync
> > Domain test resumed> 
> > error: internal error: unable to execute QEMU agent command
> > 'guest-set-time': unknown QEMU command error
> 
> Please open a new bug and attach libvirt logs.
> 
> > ######for rhel guest:
> > # virsh domtime test --sync
> > error: internal error: unable to execute QEMU agent command
> > 'guest-set-time': Invalid parameter type for 'time', expected: integer
> 
> Please attach this issue to the new bug as well.
> 
Please refer to bug 1156280.

> > BTW, I can using 'virsh resume test && virsh test domtime --now' to
> > synchronize the guest time which guest can recover to match the host time
> > after wait for more than 10 minutes.
> 
> OK, does it work with Windows?
>  
> > host info:
> > # uname -r && rpm -q qemu-kvm-rhev
> > 3.10.0-183.el7.x86_64
> > qemu-kvm-rhev-2.1.2-4.el7.x86_64
> > guest info:
> > qemu-ga-win-7.0-9
> > window 7 64bit guest
> > 
Yes, window7 64bit guest can work well with 'virsh resume test && virsh domtime test --now', i will try the winXP guest later.

Best Regards,
sluo

Comment 25 Sibiao Luo 2014-10-24 05:23:39 UTC
(In reply to Marcelo Tosatti from comment #23)
> 
> Sibiao, 
> 
> What is sufficient to test this bug is the following:
> 
> * Windows XP guest with qemu guest agent installed.
> 
> * virsh resume test && virsh domtime test --now
> 
> Under those conditions, Windows XP guest time should be correct after
> "virsh domtime" command.
Windows XP guest also worked well with qemu-kvm-rhev-2.1.2-4.el7.x86_64 executing 'virsh resume test && virsh domtime test --now'.

Best Regards,
sluo

Comment 28 Sibiao Luo 2014-10-27 03:01:10 UTC
According to comment #21-24, comment #25 and comment #27, this bug has been fixed correctly, move to VERIFIED status. Please correct me if any mistake, thanks for mtosatti and mprivozn's kindly helps.

Best Regards,
sluo

Comment 30 errata-xmlrpc 2015-03-05 09:46:28 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHSA-2015-0624.html