Re: [Qemu-devel] [PATCH v1 2/3] linux-aio: implement io plug and unplug

2014-07-01 Thread Paolo Bonzini

Il 01/07/2014 03:05, Ming Lei ha scritto:

 Busy waiting is not acceptable here (it can be unbounded if, for example, an
 NFS server is on the other side of a network partition). You have to add a
 bottom half to qemu_laio_state that calls ioq_submit, and schedule it after
 calling io_getevents.

 If the bottom half is already scheduled and the queue is full, I guess
 there's no other choice than returning -EAGAIN from ioq_enqueue and
 ultimately to the guest.

That is a bit complicated, as you mentioned it is close to
2.1 release, could we just keep it simple to return failure to guest
after retrying several times? Actually, previous dataplane handles
it by exit(-1), which is unfriendly absolutely.


Indeed, I'd say do not even bother retrying several times. :)

Paolo



[Qemu-devel] [Bug 1336123] [NEW] bad switch, segfault in hw/pci-host/bonito.c bonito_readl

2014-07-01 Thread Robin Lee
Public bug reported:

http://git.qemu.org/?p=qemu.git;a=blob;f=hw/pci-
host/bonito.c;h=56292adb03cd1a9873c2c9e5a0b2978fd0572214;hb=master#l301

The switch statement is error-prone, since two branches return the same
result.

Segfault reproducing steps:
1. make a Linux kernel(for example 3.16.0-rc2) with fuloong2e_defconfig
2. use 'qemu-system-mips64el -machine fulong2e' to boot the vmlinux

qemu versions tried: 2.0.0, 1.6.2

** Affects: qemu
 Importance: Undecided
 Status: New

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1336123

Title:
  bad switch, segfault in hw/pci-host/bonito.c bonito_readl

Status in QEMU:
  New

Bug description:
  http://git.qemu.org/?p=qemu.git;a=blob;f=hw/pci-
  host/bonito.c;h=56292adb03cd1a9873c2c9e5a0b2978fd0572214;hb=master#l301

  The switch statement is error-prone, since two branches return the
  same result.

  Segfault reproducing steps:
  1. make a Linux kernel(for example 3.16.0-rc2) with fuloong2e_defconfig
  2. use 'qemu-system-mips64el -machine fulong2e' to boot the vmlinux

  qemu versions tried: 2.0.0, 1.6.2

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1336123/+subscriptions



[Qemu-devel] [Bug 1307473] Dependencies.txt

2014-07-01 Thread Ilya Almametov
apport information

** Attachment added: Dependencies.txt
   
https://bugs.launchpad.net/bugs/1307473/+attachment/4142886/+files/Dependencies.txt

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1307473

Title:
  guest hang due to missing clock interrupt

Status in QEMU:
  New
Status in “linux” package in Ubuntu:
  Incomplete
Status in “qemu” package in Ubuntu:
  Confirmed

Bug description:
  
  I noticed on 2 different systems that after upgrade from precise to latest 
trusty VMs are crashing:

  - in case of Windows VMs I'm getting BSOD with error message: A clock 
interrupt was not received on a secondary processor within the allocated time 
interval.
  - On linux VMs I'm noticing hrtimer: interrupt took 2992229 ns messages 
  - On some proprietary virtual appliances I'm noticing crashes an due to 
missing timer interrupts

  QEMU version is:
  QEMU emulator version 1.7.91 (Debian 2.0.0~rc1+dfsg-0ubuntu3)

  Full command line:

  qemu-system-x86_64 -enable-kvm -name win7eval -S -machine pc-
  i440fx-1.7,accel=kvm,usb=off -cpu host -m 4096 -realtime mlock=off
  -smp 4,sockets=1,cores=4,threads=1 -uuid 05e5089a-
  4aa1-6bb2-ef06-ab4d020a -no-user-config -nodefaults -chardev
  
socket,id=charmonitor,path=/var/lib/libvirt/qemu/win7eval.monitor,server,nowait
  -mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime
  -no-shutdown -boot strict=on -device piix3-usb-
  uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive
  file=/var/vm/win7eval.qcow2,if=none,id=drive-virtio-disk0,format=qcow2
  -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-
  disk0,id=virtio-disk0,bootindex=1 -drive
  file=/home/damarion/iso/7600.16385.090713-1255_x86fre_enterprise_en-
  us_EVAL_Eval_Enterprise-GRMCENEVAL_EN_DVD.iso,if=none,id=drive-
  ide0-0-0,readonly=on,format=raw -device ide-cd,bus=ide.0,unit=0,drive
  =drive-ide0-0-0,id=ide0-0-0 -drive file=/home/damarion/iso/virtio-
  win-0.1-74.iso,if=none,id=drive-ide0-1-0,readonly=on,format=raw
  -device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0
  -netdev tap,fd=24,id=hostnet0 -device
  e1000,netdev=hostnet0,id=net0,mac=52:54:00:38:31:0a,bus=pci.0,addr=0x3
  -chardev pty,id=charserial0 -device isa-
  serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0
  -vnc 127.0.0.1:1 -device VGA,id=video0,bus=pci.0,addr=0x2 -device
  virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1307473/+subscriptions



[Qemu-devel] [Bug 1307473] Re: guest hang due to missing clock interrupt

2014-07-01 Thread Ilya Almametov
AlsaDevices:
 total 0
 crw-rw 1 root audio 116,  1 июня  30 18:31 seq
 crw-rw 1 root audio 116, 33 июня  30 18:31 timer
AplayDevices: Error: [Errno 2] No such file or directory
ApportVersion: 2.14.1-0ubuntu3.2
Architecture: amd64
ArecordDevices: Error: [Errno 2] No such file or directory
AudioDevicesInUse: Error: command ['fuser', '-v', '/dev/snd/seq', 
'/dev/snd/timer'] failed with exit code 1:
CRDA: Error: [Errno 2] No such file or directory
DistroRelease: Ubuntu 14.04
HibernationDevice: RESUME=UUID=ae5e2d0f-021c-46c2-8bad-0cecbdfaff95
InstallationDate: Installed on 2012-11-14 (593 days ago)
InstallationMedia: Ubuntu-Server 12.10 Quantal Quetzal - Release amd64 
(20121017.2)
MachineType: Intel Corporation S5500BC
Package: qemu 2.0.0+dfsg-2ubuntu1.1
PackageArchitecture: amd64
PciMultimedia:
 
ProcFB: 0 VESA VGA
ProcKernelCmdLine: BOOT_IMAGE=/boot/vmlinuz-3.13.0-30-generic 
root=UUID=33d72c51-8774-4af2-9549-29b9c3bd2b62 ro nomdmonddf nomdmonisw 
nomdmonddf nomdmonisw
ProcVersionSignature: Ubuntu 3.13.0-30.54-generic 3.13.11.2
RelatedPackageVersions:
 linux-restricted-modules-3.13.0-30-generic N/A
 linux-backports-modules-3.13.0-30-generic  N/A
 linux-firmware 1.127.4
RfKill: Error: [Errno 2] No such file or directory
Tags:  trusty trusty
Uname: Linux 3.13.0-30-generic x86_64
UpgradeStatus: Upgraded to trusty on 2014-06-26 (4 days ago)
UserGroups:
 
_MarkForUpload: True
dmi.bios.date: 09/09/2011
dmi.bios.vendor: Intel Corp.
dmi.bios.version: S5500.86B.01.00.0060.090920111354
dmi.board.asset.tag: 
dmi.board.name: S5500BC
dmi.board.vendor: Intel Corporation
dmi.board.version: E25124-456
dmi.chassis.asset.tag: 
dmi.chassis.type: 17
dmi.chassis.vendor: ..
dmi.chassis.version: ..
dmi.modalias: 
dmi:bvnIntelCorp.:bvrS5500.86B.01.00.0060.090920111354:bd09/09/2011:svnIntelCorporation:pnS5500BC:pvr:rvnIntelCorporation:rnS5500BC:rvrE25124-456:cvn..:ct17:cvr..:
dmi.product.name: S5500BC
dmi.product.version: 
dmi.sys.vendor: Intel Corporation


** Tags added: apport-collected trusty

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1307473

Title:
  guest hang due to missing clock interrupt

Status in QEMU:
  New
Status in “linux” package in Ubuntu:
  Incomplete
Status in “qemu” package in Ubuntu:
  Confirmed

Bug description:
  
  I noticed on 2 different systems that after upgrade from precise to latest 
trusty VMs are crashing:

  - in case of Windows VMs I'm getting BSOD with error message: A clock 
interrupt was not received on a secondary processor within the allocated time 
interval.
  - On linux VMs I'm noticing hrtimer: interrupt took 2992229 ns messages 
  - On some proprietary virtual appliances I'm noticing crashes an due to 
missing timer interrupts

  QEMU version is:
  QEMU emulator version 1.7.91 (Debian 2.0.0~rc1+dfsg-0ubuntu3)

  Full command line:

  qemu-system-x86_64 -enable-kvm -name win7eval -S -machine pc-
  i440fx-1.7,accel=kvm,usb=off -cpu host -m 4096 -realtime mlock=off
  -smp 4,sockets=1,cores=4,threads=1 -uuid 05e5089a-
  4aa1-6bb2-ef06-ab4d020a -no-user-config -nodefaults -chardev
  
socket,id=charmonitor,path=/var/lib/libvirt/qemu/win7eval.monitor,server,nowait
  -mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime
  -no-shutdown -boot strict=on -device piix3-usb-
  uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive
  file=/var/vm/win7eval.qcow2,if=none,id=drive-virtio-disk0,format=qcow2
  -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-
  disk0,id=virtio-disk0,bootindex=1 -drive
  file=/home/damarion/iso/7600.16385.090713-1255_x86fre_enterprise_en-
  us_EVAL_Eval_Enterprise-GRMCENEVAL_EN_DVD.iso,if=none,id=drive-
  ide0-0-0,readonly=on,format=raw -device ide-cd,bus=ide.0,unit=0,drive
  =drive-ide0-0-0,id=ide0-0-0 -drive file=/home/damarion/iso/virtio-
  win-0.1-74.iso,if=none,id=drive-ide0-1-0,readonly=on,format=raw
  -device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0
  -netdev tap,fd=24,id=hostnet0 -device
  e1000,netdev=hostnet0,id=net0,mac=52:54:00:38:31:0a,bus=pci.0,addr=0x3
  -chardev pty,id=charserial0 -device isa-
  serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0
  -vnc 127.0.0.1:1 -device VGA,id=video0,bus=pci.0,addr=0x2 -device
  virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1307473/+subscriptions



[Qemu-devel] [Bug 1307473] Lspci.txt

2014-07-01 Thread Ilya Almametov
apport information

** Attachment added: Lspci.txt
   https://bugs.launchpad.net/bugs/1307473/+attachment/4142888/+files/Lspci.txt

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1307473

Title:
  guest hang due to missing clock interrupt

Status in QEMU:
  New
Status in “linux” package in Ubuntu:
  Incomplete
Status in “qemu” package in Ubuntu:
  Confirmed

Bug description:
  
  I noticed on 2 different systems that after upgrade from precise to latest 
trusty VMs are crashing:

  - in case of Windows VMs I'm getting BSOD with error message: A clock 
interrupt was not received on a secondary processor within the allocated time 
interval.
  - On linux VMs I'm noticing hrtimer: interrupt took 2992229 ns messages 
  - On some proprietary virtual appliances I'm noticing crashes an due to 
missing timer interrupts

  QEMU version is:
  QEMU emulator version 1.7.91 (Debian 2.0.0~rc1+dfsg-0ubuntu3)

  Full command line:

  qemu-system-x86_64 -enable-kvm -name win7eval -S -machine pc-
  i440fx-1.7,accel=kvm,usb=off -cpu host -m 4096 -realtime mlock=off
  -smp 4,sockets=1,cores=4,threads=1 -uuid 05e5089a-
  4aa1-6bb2-ef06-ab4d020a -no-user-config -nodefaults -chardev
  
socket,id=charmonitor,path=/var/lib/libvirt/qemu/win7eval.monitor,server,nowait
  -mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime
  -no-shutdown -boot strict=on -device piix3-usb-
  uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive
  file=/var/vm/win7eval.qcow2,if=none,id=drive-virtio-disk0,format=qcow2
  -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-
  disk0,id=virtio-disk0,bootindex=1 -drive
  file=/home/damarion/iso/7600.16385.090713-1255_x86fre_enterprise_en-
  us_EVAL_Eval_Enterprise-GRMCENEVAL_EN_DVD.iso,if=none,id=drive-
  ide0-0-0,readonly=on,format=raw -device ide-cd,bus=ide.0,unit=0,drive
  =drive-ide0-0-0,id=ide0-0-0 -drive file=/home/damarion/iso/virtio-
  win-0.1-74.iso,if=none,id=drive-ide0-1-0,readonly=on,format=raw
  -device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0
  -netdev tap,fd=24,id=hostnet0 -device
  e1000,netdev=hostnet0,id=net0,mac=52:54:00:38:31:0a,bus=pci.0,addr=0x3
  -chardev pty,id=charserial0 -device isa-
  serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0
  -vnc 127.0.0.1:1 -device VGA,id=video0,bus=pci.0,addr=0x2 -device
  virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1307473/+subscriptions



[Qemu-devel] [Bug 1307473] BootDmesg.txt

2014-07-01 Thread Ilya Almametov
apport information

** Attachment added: BootDmesg.txt
   
https://bugs.launchpad.net/bugs/1307473/+attachment/4142884/+files/BootDmesg.txt

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1307473

Title:
  guest hang due to missing clock interrupt

Status in QEMU:
  New
Status in “linux” package in Ubuntu:
  Incomplete
Status in “qemu” package in Ubuntu:
  Confirmed

Bug description:
  
  I noticed on 2 different systems that after upgrade from precise to latest 
trusty VMs are crashing:

  - in case of Windows VMs I'm getting BSOD with error message: A clock 
interrupt was not received on a secondary processor within the allocated time 
interval.
  - On linux VMs I'm noticing hrtimer: interrupt took 2992229 ns messages 
  - On some proprietary virtual appliances I'm noticing crashes an due to 
missing timer interrupts

  QEMU version is:
  QEMU emulator version 1.7.91 (Debian 2.0.0~rc1+dfsg-0ubuntu3)

  Full command line:

  qemu-system-x86_64 -enable-kvm -name win7eval -S -machine pc-
  i440fx-1.7,accel=kvm,usb=off -cpu host -m 4096 -realtime mlock=off
  -smp 4,sockets=1,cores=4,threads=1 -uuid 05e5089a-
  4aa1-6bb2-ef06-ab4d020a -no-user-config -nodefaults -chardev
  
socket,id=charmonitor,path=/var/lib/libvirt/qemu/win7eval.monitor,server,nowait
  -mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime
  -no-shutdown -boot strict=on -device piix3-usb-
  uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive
  file=/var/vm/win7eval.qcow2,if=none,id=drive-virtio-disk0,format=qcow2
  -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-
  disk0,id=virtio-disk0,bootindex=1 -drive
  file=/home/damarion/iso/7600.16385.090713-1255_x86fre_enterprise_en-
  us_EVAL_Eval_Enterprise-GRMCENEVAL_EN_DVD.iso,if=none,id=drive-
  ide0-0-0,readonly=on,format=raw -device ide-cd,bus=ide.0,unit=0,drive
  =drive-ide0-0-0,id=ide0-0-0 -drive file=/home/damarion/iso/virtio-
  win-0.1-74.iso,if=none,id=drive-ide0-1-0,readonly=on,format=raw
  -device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0
  -netdev tap,fd=24,id=hostnet0 -device
  e1000,netdev=hostnet0,id=net0,mac=52:54:00:38:31:0a,bus=pci.0,addr=0x3
  -chardev pty,id=charserial0 -device isa-
  serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0
  -vnc 127.0.0.1:1 -device VGA,id=video0,bus=pci.0,addr=0x2 -device
  virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1307473/+subscriptions



[Qemu-devel] [Bug 1307473] ProcCpuinfo.txt

2014-07-01 Thread Ilya Almametov
apport information

** Attachment added: ProcCpuinfo.txt
   
https://bugs.launchpad.net/bugs/1307473/+attachment/4142890/+files/ProcCpuinfo.txt

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1307473

Title:
  guest hang due to missing clock interrupt

Status in QEMU:
  New
Status in “linux” package in Ubuntu:
  Incomplete
Status in “qemu” package in Ubuntu:
  Confirmed

Bug description:
  
  I noticed on 2 different systems that after upgrade from precise to latest 
trusty VMs are crashing:

  - in case of Windows VMs I'm getting BSOD with error message: A clock 
interrupt was not received on a secondary processor within the allocated time 
interval.
  - On linux VMs I'm noticing hrtimer: interrupt took 2992229 ns messages 
  - On some proprietary virtual appliances I'm noticing crashes an due to 
missing timer interrupts

  QEMU version is:
  QEMU emulator version 1.7.91 (Debian 2.0.0~rc1+dfsg-0ubuntu3)

  Full command line:

  qemu-system-x86_64 -enable-kvm -name win7eval -S -machine pc-
  i440fx-1.7,accel=kvm,usb=off -cpu host -m 4096 -realtime mlock=off
  -smp 4,sockets=1,cores=4,threads=1 -uuid 05e5089a-
  4aa1-6bb2-ef06-ab4d020a -no-user-config -nodefaults -chardev
  
socket,id=charmonitor,path=/var/lib/libvirt/qemu/win7eval.monitor,server,nowait
  -mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime
  -no-shutdown -boot strict=on -device piix3-usb-
  uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive
  file=/var/vm/win7eval.qcow2,if=none,id=drive-virtio-disk0,format=qcow2
  -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-
  disk0,id=virtio-disk0,bootindex=1 -drive
  file=/home/damarion/iso/7600.16385.090713-1255_x86fre_enterprise_en-
  us_EVAL_Eval_Enterprise-GRMCENEVAL_EN_DVD.iso,if=none,id=drive-
  ide0-0-0,readonly=on,format=raw -device ide-cd,bus=ide.0,unit=0,drive
  =drive-ide0-0-0,id=ide0-0-0 -drive file=/home/damarion/iso/virtio-
  win-0.1-74.iso,if=none,id=drive-ide0-1-0,readonly=on,format=raw
  -device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0
  -netdev tap,fd=24,id=hostnet0 -device
  e1000,netdev=hostnet0,id=net0,mac=52:54:00:38:31:0a,bus=pci.0,addr=0x3
  -chardev pty,id=charserial0 -device isa-
  serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0
  -vnc 127.0.0.1:1 -device VGA,id=video0,bus=pci.0,addr=0x2 -device
  virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1307473/+subscriptions



[Qemu-devel] [Bug 1307473] ProcModules.txt

2014-07-01 Thread Ilya Almametov
apport information

** Attachment added: ProcModules.txt
   
https://bugs.launchpad.net/bugs/1307473/+attachment/4142893/+files/ProcModules.txt

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1307473

Title:
  guest hang due to missing clock interrupt

Status in QEMU:
  New
Status in “linux” package in Ubuntu:
  Incomplete
Status in “qemu” package in Ubuntu:
  Confirmed

Bug description:
  
  I noticed on 2 different systems that after upgrade from precise to latest 
trusty VMs are crashing:

  - in case of Windows VMs I'm getting BSOD with error message: A clock 
interrupt was not received on a secondary processor within the allocated time 
interval.
  - On linux VMs I'm noticing hrtimer: interrupt took 2992229 ns messages 
  - On some proprietary virtual appliances I'm noticing crashes an due to 
missing timer interrupts

  QEMU version is:
  QEMU emulator version 1.7.91 (Debian 2.0.0~rc1+dfsg-0ubuntu3)

  Full command line:

  qemu-system-x86_64 -enable-kvm -name win7eval -S -machine pc-
  i440fx-1.7,accel=kvm,usb=off -cpu host -m 4096 -realtime mlock=off
  -smp 4,sockets=1,cores=4,threads=1 -uuid 05e5089a-
  4aa1-6bb2-ef06-ab4d020a -no-user-config -nodefaults -chardev
  
socket,id=charmonitor,path=/var/lib/libvirt/qemu/win7eval.monitor,server,nowait
  -mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime
  -no-shutdown -boot strict=on -device piix3-usb-
  uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive
  file=/var/vm/win7eval.qcow2,if=none,id=drive-virtio-disk0,format=qcow2
  -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-
  disk0,id=virtio-disk0,bootindex=1 -drive
  file=/home/damarion/iso/7600.16385.090713-1255_x86fre_enterprise_en-
  us_EVAL_Eval_Enterprise-GRMCENEVAL_EN_DVD.iso,if=none,id=drive-
  ide0-0-0,readonly=on,format=raw -device ide-cd,bus=ide.0,unit=0,drive
  =drive-ide0-0-0,id=ide0-0-0 -drive file=/home/damarion/iso/virtio-
  win-0.1-74.iso,if=none,id=drive-ide0-1-0,readonly=on,format=raw
  -device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0
  -netdev tap,fd=24,id=hostnet0 -device
  e1000,netdev=hostnet0,id=net0,mac=52:54:00:38:31:0a,bus=pci.0,addr=0x3
  -chardev pty,id=charserial0 -device isa-
  serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0
  -vnc 127.0.0.1:1 -device VGA,id=video0,bus=pci.0,addr=0x2 -device
  virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1307473/+subscriptions



[Qemu-devel] [Bug 1307473] IwConfig.txt

2014-07-01 Thread Ilya Almametov
apport information

** Attachment added: IwConfig.txt
   
https://bugs.launchpad.net/bugs/1307473/+attachment/4142887/+files/IwConfig.txt

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1307473

Title:
  guest hang due to missing clock interrupt

Status in QEMU:
  New
Status in “linux” package in Ubuntu:
  Incomplete
Status in “qemu” package in Ubuntu:
  Confirmed

Bug description:
  
  I noticed on 2 different systems that after upgrade from precise to latest 
trusty VMs are crashing:

  - in case of Windows VMs I'm getting BSOD with error message: A clock 
interrupt was not received on a secondary processor within the allocated time 
interval.
  - On linux VMs I'm noticing hrtimer: interrupt took 2992229 ns messages 
  - On some proprietary virtual appliances I'm noticing crashes an due to 
missing timer interrupts

  QEMU version is:
  QEMU emulator version 1.7.91 (Debian 2.0.0~rc1+dfsg-0ubuntu3)

  Full command line:

  qemu-system-x86_64 -enable-kvm -name win7eval -S -machine pc-
  i440fx-1.7,accel=kvm,usb=off -cpu host -m 4096 -realtime mlock=off
  -smp 4,sockets=1,cores=4,threads=1 -uuid 05e5089a-
  4aa1-6bb2-ef06-ab4d020a -no-user-config -nodefaults -chardev
  
socket,id=charmonitor,path=/var/lib/libvirt/qemu/win7eval.monitor,server,nowait
  -mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime
  -no-shutdown -boot strict=on -device piix3-usb-
  uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive
  file=/var/vm/win7eval.qcow2,if=none,id=drive-virtio-disk0,format=qcow2
  -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-
  disk0,id=virtio-disk0,bootindex=1 -drive
  file=/home/damarion/iso/7600.16385.090713-1255_x86fre_enterprise_en-
  us_EVAL_Eval_Enterprise-GRMCENEVAL_EN_DVD.iso,if=none,id=drive-
  ide0-0-0,readonly=on,format=raw -device ide-cd,bus=ide.0,unit=0,drive
  =drive-ide0-0-0,id=ide0-0-0 -drive file=/home/damarion/iso/virtio-
  win-0.1-74.iso,if=none,id=drive-ide0-1-0,readonly=on,format=raw
  -device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0
  -netdev tap,fd=24,id=hostnet0 -device
  e1000,netdev=hostnet0,id=net0,mac=52:54:00:38:31:0a,bus=pci.0,addr=0x3
  -chardev pty,id=charserial0 -device isa-
  serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0
  -vnc 127.0.0.1:1 -device VGA,id=video0,bus=pci.0,addr=0x2 -device
  virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1307473/+subscriptions



[Qemu-devel] [Bug 1307473] WifiSyslog.txt

2014-07-01 Thread Ilya Almametov
apport information

** Attachment added: WifiSyslog.txt
   
https://bugs.launchpad.net/bugs/1307473/+attachment/4142896/+files/WifiSyslog.txt

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1307473

Title:
  guest hang due to missing clock interrupt

Status in QEMU:
  New
Status in “linux” package in Ubuntu:
  Incomplete
Status in “qemu” package in Ubuntu:
  Confirmed

Bug description:
  
  I noticed on 2 different systems that after upgrade from precise to latest 
trusty VMs are crashing:

  - in case of Windows VMs I'm getting BSOD with error message: A clock 
interrupt was not received on a secondary processor within the allocated time 
interval.
  - On linux VMs I'm noticing hrtimer: interrupt took 2992229 ns messages 
  - On some proprietary virtual appliances I'm noticing crashes an due to 
missing timer interrupts

  QEMU version is:
  QEMU emulator version 1.7.91 (Debian 2.0.0~rc1+dfsg-0ubuntu3)

  Full command line:

  qemu-system-x86_64 -enable-kvm -name win7eval -S -machine pc-
  i440fx-1.7,accel=kvm,usb=off -cpu host -m 4096 -realtime mlock=off
  -smp 4,sockets=1,cores=4,threads=1 -uuid 05e5089a-
  4aa1-6bb2-ef06-ab4d020a -no-user-config -nodefaults -chardev
  
socket,id=charmonitor,path=/var/lib/libvirt/qemu/win7eval.monitor,server,nowait
  -mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime
  -no-shutdown -boot strict=on -device piix3-usb-
  uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive
  file=/var/vm/win7eval.qcow2,if=none,id=drive-virtio-disk0,format=qcow2
  -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-
  disk0,id=virtio-disk0,bootindex=1 -drive
  file=/home/damarion/iso/7600.16385.090713-1255_x86fre_enterprise_en-
  us_EVAL_Eval_Enterprise-GRMCENEVAL_EN_DVD.iso,if=none,id=drive-
  ide0-0-0,readonly=on,format=raw -device ide-cd,bus=ide.0,unit=0,drive
  =drive-ide0-0-0,id=ide0-0-0 -drive file=/home/damarion/iso/virtio-
  win-0.1-74.iso,if=none,id=drive-ide0-1-0,readonly=on,format=raw
  -device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0
  -netdev tap,fd=24,id=hostnet0 -device
  e1000,netdev=hostnet0,id=net0,mac=52:54:00:38:31:0a,bus=pci.0,addr=0x3
  -chardev pty,id=charserial0 -device isa-
  serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0
  -vnc 127.0.0.1:1 -device VGA,id=video0,bus=pci.0,addr=0x2 -device
  virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1307473/+subscriptions



[Qemu-devel] [Bug 1307473] UdevDb.txt

2014-07-01 Thread Ilya Almametov
apport information

** Attachment added: UdevDb.txt
   https://bugs.launchpad.net/bugs/1307473/+attachment/4142894/+files/UdevDb.txt

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1307473

Title:
  guest hang due to missing clock interrupt

Status in QEMU:
  New
Status in “linux” package in Ubuntu:
  Incomplete
Status in “qemu” package in Ubuntu:
  Confirmed

Bug description:
  
  I noticed on 2 different systems that after upgrade from precise to latest 
trusty VMs are crashing:

  - in case of Windows VMs I'm getting BSOD with error message: A clock 
interrupt was not received on a secondary processor within the allocated time 
interval.
  - On linux VMs I'm noticing hrtimer: interrupt took 2992229 ns messages 
  - On some proprietary virtual appliances I'm noticing crashes an due to 
missing timer interrupts

  QEMU version is:
  QEMU emulator version 1.7.91 (Debian 2.0.0~rc1+dfsg-0ubuntu3)

  Full command line:

  qemu-system-x86_64 -enable-kvm -name win7eval -S -machine pc-
  i440fx-1.7,accel=kvm,usb=off -cpu host -m 4096 -realtime mlock=off
  -smp 4,sockets=1,cores=4,threads=1 -uuid 05e5089a-
  4aa1-6bb2-ef06-ab4d020a -no-user-config -nodefaults -chardev
  
socket,id=charmonitor,path=/var/lib/libvirt/qemu/win7eval.monitor,server,nowait
  -mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime
  -no-shutdown -boot strict=on -device piix3-usb-
  uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive
  file=/var/vm/win7eval.qcow2,if=none,id=drive-virtio-disk0,format=qcow2
  -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-
  disk0,id=virtio-disk0,bootindex=1 -drive
  file=/home/damarion/iso/7600.16385.090713-1255_x86fre_enterprise_en-
  us_EVAL_Eval_Enterprise-GRMCENEVAL_EN_DVD.iso,if=none,id=drive-
  ide0-0-0,readonly=on,format=raw -device ide-cd,bus=ide.0,unit=0,drive
  =drive-ide0-0-0,id=ide0-0-0 -drive file=/home/damarion/iso/virtio-
  win-0.1-74.iso,if=none,id=drive-ide0-1-0,readonly=on,format=raw
  -device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0
  -netdev tap,fd=24,id=hostnet0 -device
  e1000,netdev=hostnet0,id=net0,mac=52:54:00:38:31:0a,bus=pci.0,addr=0x3
  -chardev pty,id=charserial0 -device isa-
  serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0
  -vnc 127.0.0.1:1 -device VGA,id=video0,bus=pci.0,addr=0x2 -device
  virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1307473/+subscriptions



[Qemu-devel] [Bug 1307473] Lsusb.txt

2014-07-01 Thread Ilya Almametov
apport information

** Attachment added: Lsusb.txt
   https://bugs.launchpad.net/bugs/1307473/+attachment/4142889/+files/Lsusb.txt

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1307473

Title:
  guest hang due to missing clock interrupt

Status in QEMU:
  New
Status in “linux” package in Ubuntu:
  Incomplete
Status in “qemu” package in Ubuntu:
  Confirmed

Bug description:
  
  I noticed on 2 different systems that after upgrade from precise to latest 
trusty VMs are crashing:

  - in case of Windows VMs I'm getting BSOD with error message: A clock 
interrupt was not received on a secondary processor within the allocated time 
interval.
  - On linux VMs I'm noticing hrtimer: interrupt took 2992229 ns messages 
  - On some proprietary virtual appliances I'm noticing crashes an due to 
missing timer interrupts

  QEMU version is:
  QEMU emulator version 1.7.91 (Debian 2.0.0~rc1+dfsg-0ubuntu3)

  Full command line:

  qemu-system-x86_64 -enable-kvm -name win7eval -S -machine pc-
  i440fx-1.7,accel=kvm,usb=off -cpu host -m 4096 -realtime mlock=off
  -smp 4,sockets=1,cores=4,threads=1 -uuid 05e5089a-
  4aa1-6bb2-ef06-ab4d020a -no-user-config -nodefaults -chardev
  
socket,id=charmonitor,path=/var/lib/libvirt/qemu/win7eval.monitor,server,nowait
  -mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime
  -no-shutdown -boot strict=on -device piix3-usb-
  uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive
  file=/var/vm/win7eval.qcow2,if=none,id=drive-virtio-disk0,format=qcow2
  -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-
  disk0,id=virtio-disk0,bootindex=1 -drive
  file=/home/damarion/iso/7600.16385.090713-1255_x86fre_enterprise_en-
  us_EVAL_Eval_Enterprise-GRMCENEVAL_EN_DVD.iso,if=none,id=drive-
  ide0-0-0,readonly=on,format=raw -device ide-cd,bus=ide.0,unit=0,drive
  =drive-ide0-0-0,id=ide0-0-0 -drive file=/home/damarion/iso/virtio-
  win-0.1-74.iso,if=none,id=drive-ide0-1-0,readonly=on,format=raw
  -device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0
  -netdev tap,fd=24,id=hostnet0 -device
  e1000,netdev=hostnet0,id=net0,mac=52:54:00:38:31:0a,bus=pci.0,addr=0x3
  -chardev pty,id=charserial0 -device isa-
  serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0
  -vnc 127.0.0.1:1 -device VGA,id=video0,bus=pci.0,addr=0x2 -device
  virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1307473/+subscriptions



[Qemu-devel] [Bug 1307473] UdevLog.txt

2014-07-01 Thread Ilya Almametov
apport information

** Attachment added: UdevLog.txt
   
https://bugs.launchpad.net/bugs/1307473/+attachment/4142895/+files/UdevLog.txt

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1307473

Title:
  guest hang due to missing clock interrupt

Status in QEMU:
  New
Status in “linux” package in Ubuntu:
  Incomplete
Status in “qemu” package in Ubuntu:
  Confirmed

Bug description:
  
  I noticed on 2 different systems that after upgrade from precise to latest 
trusty VMs are crashing:

  - in case of Windows VMs I'm getting BSOD with error message: A clock 
interrupt was not received on a secondary processor within the allocated time 
interval.
  - On linux VMs I'm noticing hrtimer: interrupt took 2992229 ns messages 
  - On some proprietary virtual appliances I'm noticing crashes an due to 
missing timer interrupts

  QEMU version is:
  QEMU emulator version 1.7.91 (Debian 2.0.0~rc1+dfsg-0ubuntu3)

  Full command line:

  qemu-system-x86_64 -enable-kvm -name win7eval -S -machine pc-
  i440fx-1.7,accel=kvm,usb=off -cpu host -m 4096 -realtime mlock=off
  -smp 4,sockets=1,cores=4,threads=1 -uuid 05e5089a-
  4aa1-6bb2-ef06-ab4d020a -no-user-config -nodefaults -chardev
  
socket,id=charmonitor,path=/var/lib/libvirt/qemu/win7eval.monitor,server,nowait
  -mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime
  -no-shutdown -boot strict=on -device piix3-usb-
  uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive
  file=/var/vm/win7eval.qcow2,if=none,id=drive-virtio-disk0,format=qcow2
  -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-
  disk0,id=virtio-disk0,bootindex=1 -drive
  file=/home/damarion/iso/7600.16385.090713-1255_x86fre_enterprise_en-
  us_EVAL_Eval_Enterprise-GRMCENEVAL_EN_DVD.iso,if=none,id=drive-
  ide0-0-0,readonly=on,format=raw -device ide-cd,bus=ide.0,unit=0,drive
  =drive-ide0-0-0,id=ide0-0-0 -drive file=/home/damarion/iso/virtio-
  win-0.1-74.iso,if=none,id=drive-ide0-1-0,readonly=on,format=raw
  -device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0
  -netdev tap,fd=24,id=hostnet0 -device
  e1000,netdev=hostnet0,id=net0,mac=52:54:00:38:31:0a,bus=pci.0,addr=0x3
  -chardev pty,id=charserial0 -device isa-
  serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0
  -vnc 127.0.0.1:1 -device VGA,id=video0,bus=pci.0,addr=0x2 -device
  virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1307473/+subscriptions



[Qemu-devel] [Bug 1307473] ProcEnviron.txt

2014-07-01 Thread Ilya Almametov
apport information

** Attachment added: ProcEnviron.txt
   
https://bugs.launchpad.net/bugs/1307473/+attachment/4142891/+files/ProcEnviron.txt

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1307473

Title:
  guest hang due to missing clock interrupt

Status in QEMU:
  New
Status in “linux” package in Ubuntu:
  Incomplete
Status in “qemu” package in Ubuntu:
  Confirmed

Bug description:
  
  I noticed on 2 different systems that after upgrade from precise to latest 
trusty VMs are crashing:

  - in case of Windows VMs I'm getting BSOD with error message: A clock 
interrupt was not received on a secondary processor within the allocated time 
interval.
  - On linux VMs I'm noticing hrtimer: interrupt took 2992229 ns messages 
  - On some proprietary virtual appliances I'm noticing crashes an due to 
missing timer interrupts

  QEMU version is:
  QEMU emulator version 1.7.91 (Debian 2.0.0~rc1+dfsg-0ubuntu3)

  Full command line:

  qemu-system-x86_64 -enable-kvm -name win7eval -S -machine pc-
  i440fx-1.7,accel=kvm,usb=off -cpu host -m 4096 -realtime mlock=off
  -smp 4,sockets=1,cores=4,threads=1 -uuid 05e5089a-
  4aa1-6bb2-ef06-ab4d020a -no-user-config -nodefaults -chardev
  
socket,id=charmonitor,path=/var/lib/libvirt/qemu/win7eval.monitor,server,nowait
  -mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime
  -no-shutdown -boot strict=on -device piix3-usb-
  uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive
  file=/var/vm/win7eval.qcow2,if=none,id=drive-virtio-disk0,format=qcow2
  -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-
  disk0,id=virtio-disk0,bootindex=1 -drive
  file=/home/damarion/iso/7600.16385.090713-1255_x86fre_enterprise_en-
  us_EVAL_Eval_Enterprise-GRMCENEVAL_EN_DVD.iso,if=none,id=drive-
  ide0-0-0,readonly=on,format=raw -device ide-cd,bus=ide.0,unit=0,drive
  =drive-ide0-0-0,id=ide0-0-0 -drive file=/home/damarion/iso/virtio-
  win-0.1-74.iso,if=none,id=drive-ide0-1-0,readonly=on,format=raw
  -device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0
  -netdev tap,fd=24,id=hostnet0 -device
  e1000,netdev=hostnet0,id=net0,mac=52:54:00:38:31:0a,bus=pci.0,addr=0x3
  -chardev pty,id=charserial0 -device isa-
  serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0
  -vnc 127.0.0.1:1 -device VGA,id=video0,bus=pci.0,addr=0x2 -device
  virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1307473/+subscriptions



[Qemu-devel] [Bug 1307473] ProcInterrupts.txt

2014-07-01 Thread Ilya Almametov
apport information

** Attachment added: ProcInterrupts.txt
   
https://bugs.launchpad.net/bugs/1307473/+attachment/4142892/+files/ProcInterrupts.txt

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1307473

Title:
  guest hang due to missing clock interrupt

Status in QEMU:
  New
Status in “linux” package in Ubuntu:
  Incomplete
Status in “qemu” package in Ubuntu:
  Confirmed

Bug description:
  
  I noticed on 2 different systems that after upgrade from precise to latest 
trusty VMs are crashing:

  - in case of Windows VMs I'm getting BSOD with error message: A clock 
interrupt was not received on a secondary processor within the allocated time 
interval.
  - On linux VMs I'm noticing hrtimer: interrupt took 2992229 ns messages 
  - On some proprietary virtual appliances I'm noticing crashes an due to 
missing timer interrupts

  QEMU version is:
  QEMU emulator version 1.7.91 (Debian 2.0.0~rc1+dfsg-0ubuntu3)

  Full command line:

  qemu-system-x86_64 -enable-kvm -name win7eval -S -machine pc-
  i440fx-1.7,accel=kvm,usb=off -cpu host -m 4096 -realtime mlock=off
  -smp 4,sockets=1,cores=4,threads=1 -uuid 05e5089a-
  4aa1-6bb2-ef06-ab4d020a -no-user-config -nodefaults -chardev
  
socket,id=charmonitor,path=/var/lib/libvirt/qemu/win7eval.monitor,server,nowait
  -mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime
  -no-shutdown -boot strict=on -device piix3-usb-
  uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive
  file=/var/vm/win7eval.qcow2,if=none,id=drive-virtio-disk0,format=qcow2
  -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-
  disk0,id=virtio-disk0,bootindex=1 -drive
  file=/home/damarion/iso/7600.16385.090713-1255_x86fre_enterprise_en-
  us_EVAL_Eval_Enterprise-GRMCENEVAL_EN_DVD.iso,if=none,id=drive-
  ide0-0-0,readonly=on,format=raw -device ide-cd,bus=ide.0,unit=0,drive
  =drive-ide0-0-0,id=ide0-0-0 -drive file=/home/damarion/iso/virtio-
  win-0.1-74.iso,if=none,id=drive-ide0-1-0,readonly=on,format=raw
  -device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0
  -netdev tap,fd=24,id=hostnet0 -device
  e1000,netdev=hostnet0,id=net0,mac=52:54:00:38:31:0a,bus=pci.0,addr=0x3
  -chardev pty,id=charserial0 -device isa-
  serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0
  -vnc 127.0.0.1:1 -device VGA,id=video0,bus=pci.0,addr=0x2 -device
  virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1307473/+subscriptions



[Qemu-devel] [Bug 1307473] CurrentDmesg.txt

2014-07-01 Thread Ilya Almametov
apport information

** Attachment added: CurrentDmesg.txt
   
https://bugs.launchpad.net/bugs/1307473/+attachment/4142885/+files/CurrentDmesg.txt

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1307473

Title:
  guest hang due to missing clock interrupt

Status in QEMU:
  New
Status in “linux” package in Ubuntu:
  Incomplete
Status in “qemu” package in Ubuntu:
  Confirmed

Bug description:
  
  I noticed on 2 different systems that after upgrade from precise to latest 
trusty VMs are crashing:

  - in case of Windows VMs I'm getting BSOD with error message: A clock 
interrupt was not received on a secondary processor within the allocated time 
interval.
  - On linux VMs I'm noticing hrtimer: interrupt took 2992229 ns messages 
  - On some proprietary virtual appliances I'm noticing crashes an due to 
missing timer interrupts

  QEMU version is:
  QEMU emulator version 1.7.91 (Debian 2.0.0~rc1+dfsg-0ubuntu3)

  Full command line:

  qemu-system-x86_64 -enable-kvm -name win7eval -S -machine pc-
  i440fx-1.7,accel=kvm,usb=off -cpu host -m 4096 -realtime mlock=off
  -smp 4,sockets=1,cores=4,threads=1 -uuid 05e5089a-
  4aa1-6bb2-ef06-ab4d020a -no-user-config -nodefaults -chardev
  
socket,id=charmonitor,path=/var/lib/libvirt/qemu/win7eval.monitor,server,nowait
  -mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime
  -no-shutdown -boot strict=on -device piix3-usb-
  uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive
  file=/var/vm/win7eval.qcow2,if=none,id=drive-virtio-disk0,format=qcow2
  -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-
  disk0,id=virtio-disk0,bootindex=1 -drive
  file=/home/damarion/iso/7600.16385.090713-1255_x86fre_enterprise_en-
  us_EVAL_Eval_Enterprise-GRMCENEVAL_EN_DVD.iso,if=none,id=drive-
  ide0-0-0,readonly=on,format=raw -device ide-cd,bus=ide.0,unit=0,drive
  =drive-ide0-0-0,id=ide0-0-0 -drive file=/home/damarion/iso/virtio-
  win-0.1-74.iso,if=none,id=drive-ide0-1-0,readonly=on,format=raw
  -device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0
  -netdev tap,fd=24,id=hostnet0 -device
  e1000,netdev=hostnet0,id=net0,mac=52:54:00:38:31:0a,bus=pci.0,addr=0x3
  -chardev pty,id=charserial0 -device isa-
  serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0
  -vnc 127.0.0.1:1 -device VGA,id=video0,bus=pci.0,addr=0x2 -device
  virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1307473/+subscriptions



[Qemu-devel] [Bug 1307473] Re: guest hang due to missing clock interrupt

2014-07-01 Thread Ilya Almametov
** Changed in: linux (Ubuntu)
   Status: Incomplete = Confirmed

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1307473

Title:
  guest hang due to missing clock interrupt

Status in QEMU:
  New
Status in “linux” package in Ubuntu:
  Confirmed
Status in “qemu” package in Ubuntu:
  Confirmed

Bug description:
  
  I noticed on 2 different systems that after upgrade from precise to latest 
trusty VMs are crashing:

  - in case of Windows VMs I'm getting BSOD with error message: A clock 
interrupt was not received on a secondary processor within the allocated time 
interval.
  - On linux VMs I'm noticing hrtimer: interrupt took 2992229 ns messages 
  - On some proprietary virtual appliances I'm noticing crashes an due to 
missing timer interrupts

  QEMU version is:
  QEMU emulator version 1.7.91 (Debian 2.0.0~rc1+dfsg-0ubuntu3)

  Full command line:

  qemu-system-x86_64 -enable-kvm -name win7eval -S -machine pc-
  i440fx-1.7,accel=kvm,usb=off -cpu host -m 4096 -realtime mlock=off
  -smp 4,sockets=1,cores=4,threads=1 -uuid 05e5089a-
  4aa1-6bb2-ef06-ab4d020a -no-user-config -nodefaults -chardev
  
socket,id=charmonitor,path=/var/lib/libvirt/qemu/win7eval.monitor,server,nowait
  -mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime
  -no-shutdown -boot strict=on -device piix3-usb-
  uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive
  file=/var/vm/win7eval.qcow2,if=none,id=drive-virtio-disk0,format=qcow2
  -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-
  disk0,id=virtio-disk0,bootindex=1 -drive
  file=/home/damarion/iso/7600.16385.090713-1255_x86fre_enterprise_en-
  us_EVAL_Eval_Enterprise-GRMCENEVAL_EN_DVD.iso,if=none,id=drive-
  ide0-0-0,readonly=on,format=raw -device ide-cd,bus=ide.0,unit=0,drive
  =drive-ide0-0-0,id=ide0-0-0 -drive file=/home/damarion/iso/virtio-
  win-0.1-74.iso,if=none,id=drive-ide0-1-0,readonly=on,format=raw
  -device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0
  -netdev tap,fd=24,id=hostnet0 -device
  e1000,netdev=hostnet0,id=net0,mac=52:54:00:38:31:0a,bus=pci.0,addr=0x3
  -chardev pty,id=charserial0 -device isa-
  serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0
  -vnc 127.0.0.1:1 -device VGA,id=video0,bus=pci.0,addr=0x2 -device
  virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1307473/+subscriptions



Re: [Qemu-devel] [PATCH fix for 2.1] makefile: Fix tools compile

2014-07-01 Thread Paolo Bonzini

Il 01/07/2014 07:42, Alexey Kardashevskiy ha scritto:

This is wrong actually. The problem here that compiler knows how to
optimize constants. sin(0.0) is the one while log(0.0) is not (it is
supposed to throw error or something as it the result is infinity).

So the correct test here could be:
int main(void) { volatile double x = 1; return isnan(sin(x)); }

But I am afraid pretty soon compilers will learn how to optimize this as
well :)


I think something like double x; int f(void) {return isnan(sin(x));} 
should be bullet proof.


Paolo



[Qemu-devel] [RFC PATCH V4 2/2] qemu: support xen hvm direct kernel boot

2014-07-01 Thread Chunyan Liu
qemu side patch to support xen HVM direct kernel boot:
if -kernel exists, calls xen_load_linux(), which will read kernel/initrd
and add a linuxboot.bin or multiboot.bin option rom. The
linuxboot.bin/multiboot.bin will load kernel/initrd and jump to execute
kernel directly. It's working when xen uses seabios.

During this work, found the 'kvmvapic' is in option_rom list, it should
not be there in xen case. Set s-vapic_control = 0 in xen_apic_realize()
to handle that.

Signed-off-by: Chunyan Liu cy...@suse.com
---
Changes to v3:
  - add assertion before adding option rom as Stefan suggests

 hw/i386/pc.c   | 25 +
 hw/i386/pc_piix.c  |  7 +++
 hw/i386/xen/xen_apic.c |  1 +
 include/hw/i386/pc.h   |  5 +
 4 files changed, 38 insertions(+)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 2cf22b1..9e58982 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1190,6 +1190,31 @@ void pc_acpi_init(const char *default_dsdt)
 }
 }
 
+FWCfgState *xen_load_linux(const char *kernel_filename,
+   const char *kernel_cmdline,
+   const char *initrd_filename,
+   ram_addr_t below_4g_mem_size,
+   PcGuestInfo *guest_info)
+{
+int i;
+FWCfgState *fw_cfg;
+
+assert(kernel_filename != NULL);
+
+fw_cfg = fw_cfg_init(BIOS_CFG_IOPORT, BIOS_CFG_IOPORT + 1, 0, 0);
+rom_set_fw(fw_cfg);
+
+load_linux(fw_cfg, kernel_filename, initrd_filename,
+   kernel_cmdline, below_4g_mem_size);
+for (i = 0; i  nb_option_roms; i++) {
+assert(!strcmp(option_rom[i].name, linuxboot.bin) ||
+   !strcmp(option_rom[i].name, multiboot.bin));
+rom_add_option(option_rom[i].name, option_rom[i].bootindex);
+}
+guest_info-fw_cfg = fw_cfg;
+return fw_cfg;
+}
+
 FWCfgState *pc_memory_init(MachineState *machine,
MemoryRegion *system_memory,
ram_addr_t below_4g_mem_size,
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 2dccb34..63e2198 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -180,6 +180,13 @@ static void pc_init1(MachineState *machine,
 fw_cfg = pc_memory_init(machine, system_memory,
 below_4g_mem_size, above_4g_mem_size,
 rom_memory, ram_memory, guest_info);
+} else if (machine-kernel_filename != NULL) {
+/* For xen HVM direct kernel boot, load linux here */
+fw_cfg = xen_load_linux(machine-kernel_filename,
+machine-kernel_cmdline,
+machine-initrd_filename,
+below_4g_mem_size,
+guest_info);
 }
 
 gsi_state = g_malloc0(sizeof(*gsi_state));
diff --git a/hw/i386/xen/xen_apic.c b/hw/i386/xen/xen_apic.c
index 63bb7f7..f5acd6a 100644
--- a/hw/i386/xen/xen_apic.c
+++ b/hw/i386/xen/xen_apic.c
@@ -40,6 +40,7 @@ static void xen_apic_realize(DeviceState *dev, Error **errp)
 {
 APICCommonState *s = APIC_COMMON(dev);
 
+s-vapic_control = 0;
 memory_region_init_io(s-io_memory, OBJECT(s), xen_apic_io_ops, s,
   xen-apic-msi, APIC_SPACE_SIZE);
 
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 1c0c382..b47aaa9 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -187,6 +187,11 @@ PcGuestInfo *pc_guest_info_init(ram_addr_t 
below_4g_mem_size,
 void pc_pci_as_mapping_init(Object *owner, MemoryRegion *system_memory,
 MemoryRegion *pci_address_space);
 
+FWCfgState *xen_load_linux(const char *kernel_filename,
+   const char *kernel_cmdline,
+   const char *initrd_filename,
+   ram_addr_t below_4g_mem_size,
+   PcGuestInfo *guest_info);
 FWCfgState *pc_memory_init(MachineState *machine,
MemoryRegion *system_memory,
ram_addr_t below_4g_mem_size,
-- 
1.8.4.5




[Qemu-devel] [RFC PATCH V4 1/2] xen: pass kernel initrd to qemu

2014-07-01 Thread Chunyan Liu
xen side patch to support xen HVM direct kernel boot:
support 'kernel', 'ramdisk', 'cmdline' (and 'root', 'extra' as well
which would be deprecated later) in HVM config file, parse config file,
pass -kernel, -initrd, -append parameters to qemu.

It's working with qemu-xen when using the default BIOS (seabios).

[config example]
kernel=/mnt/vmlinuz-3.0.13-0.27-default
ramdisk=/mnt/initrd-3.0.13-0.27-default
root=/dev/hda2
extra=console=tty0 console=ttyS0

Signed-off-by: Chunyan Liu cy...@suse.com
---
Changes to v3:
  address to Ian J's comments:
  - 'root' and 'extra' might be useful for future
extension, so drop 'cmdline' replacing 'root' and 'extra'
implementation introduced in v3, keep existing way.
  - move 'kernel','ramdisk','cmdline' to libxl_domain_build_info common
areas, rather then adding to .u.hvm. But for compatibility, keep
.u.pv.kernel, .u.pv.ramdisk, .u.pv.cmdline.
  - update libxl.h to indicate the new changes: add
LIBXL_HAVE_BUILDINFO_KERNEL
LIBXL_HAVE_BUILDINFO_RAMDISK 
LIBXL_HAVE_BUILDINFO_CMDLINE
  - update description in man page to make it more clear

 docs/man/xl.cfg.pod.5   | 53 +
 tools/libxl/libxl.h | 38 ++
 tools/libxl/libxl_dm.c  | 15 
 tools/libxl/libxl_types.idl |  3 +++
 tools/libxl/xl_cmdimpl.c| 57 -
 5 files changed, 124 insertions(+), 42 deletions(-)

diff --git a/docs/man/xl.cfg.pod.5 b/docs/man/xl.cfg.pod.5
index c087cbc..5833908 100644
--- a/docs/man/xl.cfg.pod.5
+++ b/docs/man/xl.cfg.pod.5
@@ -304,6 +304,37 @@ Action to take if the domain crashes.  Default is 
Cdestroy.
 
 =back
 
+=head3 Direct Kernel Boot
+
+Direct kernel boot allows booting directly from a kernel and initrd
+stored in the host physical machine OS, allowing command line arguments
+to be passed directly. PV guest direct kernel boot is supported. HVM
+guest direct kernel boot is supported with limitation (it's supported
+when using qemu-xen and default BIOS 'seabios'; not supported in case of
+stubdom-dm and old rombios.)
+
+=over 4
+
+=item Bkernel=PATHNAME
+
+Load the specified file as the kernel image.
+
+=item Bramdisk=PATHNAME
+
+Load the specified file as the ramdisk.
+
+=item Broot=STRING
+
+Append Broot=STRING to the kernel command line (Note: it is guest
+specific what meaning this has).
+
+=item Bextra=STRING
+
+Append BSTRING to the kernel command line. (Note: it is guest
+specific what meaning this has).
+
+=back
+
 =head3 Other Options
 
 =over 4
@@ -646,20 +677,12 @@ The following options apply only to Paravirtual guests.
 
 =over 4
 
-=item Bkernel=PATHNAME
-
-Load the specified file as the kernel image.  Either Bkernel or
-Bbootloader must be specified for PV guests.
-
-=item Bramdisk=PATHNAME
-
-Load the specified file as the ramdisk.
-
 =item Bbootloader=PROGRAM
 
 Run CPROGRAM to find the kernel image and ramdisk to use.  Normally
 CPROGRAM would be Cpygrub, which is an emulation of
-grub/grub2/syslinux.
+grub/grub2/syslinux. Either Bkernel or Bbootloader must be specified
+for PV guests.
 
 =item Bbootloader_args=[ ARG, ARG, ...]
 
@@ -667,16 +690,6 @@ Append BARGs to the arguments to the Bbootloader
 program. Alternatively if the argument is a simple string then it will
 be split into words at whitespace (this second option is deprecated).
 
-=item Broot=STRING
-
-Append Broot=STRING to the kernel command line (Note: it is guest
-specific what meaning this has).
-
-=item Bextra=STRING
-
-Append BSTRING to the kernel command line. Note: it is guest
-specific what meaning this has).
-
 =item Be820_host=BOOLEAN
 
 Selects whether to expose the host e820 (memory map) to the guest via
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index 69ceac8..a45415d 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -493,6 +493,44 @@ typedef struct libxl__ctx libxl_ctx;
  */
 #define LIBXL_HAVE_DEVICE_PCI_SEIZE 1
 
+/*
+ * LIBXL_HAVE_BUILDINFO_KERNEL
+ *
+ * If this is defined, then the libxl_domain_build_info structure will
+ * contain 'kernel' string field. It is to indicate kernel image location,
+ * for both PV and HVM guest to do direct kernel boot. For compatibility,
+ * u.pv.kernel still exists, but it might be deprecated in future.
+ *
+ * If it is set, guest will be booted from the indicated kernel.
+ */
+#define LIBXL_HAVE_BUILDINFO_KERNEL 1
+
+/*
+ * LIBXL_HAVE_BUILDINFO_RAMDISK
+ *
+ * If this is defined, then the libxl_domain_build_info structure will
+ * contain 'ramdisk' string field. It is to indicate ramdisk location,
+ * for both PV and HVM guest to do direct kernel boot. For compatibility,
+ * u.pv.ramdisk still exists, but it might be deprecated in future.
+ *
+ * If it is set, guest will be booted from indicated kernel and ramdisk.
+ */
+#define LIBXL_HAVE_BUILDINFO_RAMDISK 1
+
+/*
+ * LIBXL_HAVE_BUILDINFO_CMDLINE
+ *
+ * If this is defined, then the libxl_domain_build_info structure will
+ 

[Qemu-devel] [RFC PATCH V4 0/2] Support xen HVM direct kernel boot

2014-07-01 Thread Chunyan Liu
Updated current patch series for working with qemu-xen and default
BIOS (seabios), to make it in good shape. Stubdom support will be
continued.
  
xen side patch: pass kernel/initrd/append parameters to qemu-dm
qemu side patch: reuse load_linux() for xen hvm direct kernel boot.
Different from pc_memory_init which does lots of ram alloc work
and rom/bios loading work, for xen, we only need to init a basic
fw_cfg device used by load_linux() to store ADDRs and
linuxboot.bin/multiboot.bin to retrive ADDRs, then load_linux(),
after that, do real add option rom work to add
linuxboot.bin/multiboot.bin to system option rom. Other things
would be done by seabios smoothly.

Changes:
  xen side patch:
  - address to Ian J's comments:
- drop 'cmdline' replacing 'root' and 'extra' implementation
  introduced in v3.
- move 'kernel','ramdisk','cmdline' to libxl_domain_build_info
  common areas, rather then adding to .u.hvm.
- update libxl.h to indicate the new changes
  qemu side patch:
  - add assertion
  - add description about vapic changes.

v3 is here:
https://lists.nongnu.org/archive/html/qemu-devel/2014-06/msg04903.html

v2 is here:
http://thread.gmane.org/gmane.comp.emulators.qemu/277514

v1 is here:
http://lists.gnu.org/archive/html/qemu-devel/2014-05/msg06233.html

Chunyan Liu (2):
  xen: pass kernel initrd to qemu
  qemu: support xen HVM direct kernel boot

-- 
1.8.4.5




Re: [Qemu-devel] [RFC 01/14] vga: Create direct sufaces for depth 24 too

2014-07-01 Thread Gerd Hoffmann
  Hi,

 -if (depth == 32 || ((depth == 16 || depth == 15)  !byteswap)) {
 + if (depth == 32 || depth == 24 ||
 +   ((depth == 16 || depth == 15)  !byteswap)) {

Doesn't apply.  depth == 15 isn't upstream.  Guess you have some more
local changes?  Also the whitespace looks fishy (tabs vs. spaces?).
Note that the qemu whitespace codestyle (spaces only) differs from linux
kernel ...

cheers,
  Gerd





Re: [Qemu-devel] [PATCH v3] vhost-user: fix regions provied with VHOST_USER_SET_MEM_TABLE message

2014-07-01 Thread Michael S. Tsirkin
On Thu, Jun 26, 2014 at 11:01:32PM +0200, Damjan Marion wrote:
 Old code was affected by memory gaps which resulted in buffer pointers
 pointing to address outside of the mapped regions.
 
 Here we are introducing following changes:
  - new function qemu_get_ram_block_host_ptr() returns host pointer
to the ram block, it is needed to calculate offset of specific
region in the host memory
  - new field mmap_offset is added to the VhostUserMemoryRegion. It
contains offset where specific region starts in the mapped memory.
As there is stil no wider adoption of vhost-user agreement was made
that we will not bump version number due to this change
  - other fileds in VhostUserMemoryRegion struct are not changed, as
they are all needed for usermode app implementation
  - region data is not taken from ram_list.blocks anymore, instead we
use region data which is alredy calculated for use in vhost-net
  - Now multiple regions can have same FD and user applicaton can call
mmap() multiple times with the same FD but with different offset
(user needs to take care for offset page alignment)
 
 Signed-off-by: Damjan Marion damar...@cisco.com

Please add a unit test for this as well.


 ---
  docs/specs/vhost-user.txt |  7 ---
  exec.c|  7 +++
  hw/virtio/vhost-user.c| 23 ++-
  include/exec/ram_addr.h   |  1 +
  4 files changed, 26 insertions(+), 12 deletions(-)
 
 diff --git a/docs/specs/vhost-user.txt b/docs/specs/vhost-user.txt
 index 2641390..6abb697 100644
 --- a/docs/specs/vhost-user.txt
 +++ b/docs/specs/vhost-user.txt
 @@ -78,13 +78,14 @@ Depending on the request type, payload can be:
 Padding: 32-bit
  
 A region is:
 -   ---
 -   | guest address | size | user address |
 -   ---
 +   -
 +   | guest address | size | user address | mmap offset |
 +   -
  
 Guest address: a 64-bit guest address of the region
 Size: a 64-bit size
 User address: a 64-bit user address
 +   mmmap offset: 64-bit offset where region starts in the mapped memory
  
  
  In QEMU the vhost-user message is implemented with the following struct:
 diff --git a/exec.c b/exec.c
 index c849405..a94c583 100644
 --- a/exec.c
 +++ b/exec.c
 @@ -1456,6 +1456,13 @@ int qemu_get_ram_fd(ram_addr_t addr)
  return block-fd;
  }
  
 +void *qemu_get_ram_block_host_ptr(ram_addr_t addr)
 +{
 +RAMBlock *block = qemu_get_ram_block(addr);
 +
 +return block-host;
 +}
 +
  /* Return a host pointer to ram allocated with qemu_ram_alloc.
 With the exception of the softmmu code in this file, this should
 only be used for local memory (e.g. video ram) that the device owns,
 diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
 index 0df6a93..38e5806 100644
 --- a/hw/virtio/vhost-user.c
 +++ b/hw/virtio/vhost-user.c
 @@ -14,6 +14,7 @@
  #include sysemu/kvm.h
  #include qemu/error-report.h
  #include qemu/sockets.h
 +#include exec/ram_addr.h
  
  #include fcntl.h
  #include unistd.h
 @@ -47,6 +48,7 @@ typedef struct VhostUserMemoryRegion {
  uint64_t guest_phys_addr;
  uint64_t memory_size;
  uint64_t userspace_addr;
 +uint64_t mmap_offset;
  } VhostUserMemoryRegion;
  
  typedef struct VhostUserMemory {
 @@ -183,10 +185,10 @@ static int vhost_user_call(struct vhost_dev *dev, 
 unsigned long int request,
  {
  VhostUserMsg msg;
  VhostUserRequest msg_request;
 -RAMBlock *block = 0;
  struct vhost_vring_file *file = 0;
  int need_reply = 0;
  int fds[VHOST_MEMORY_MAX_NREGIONS];
 +int i, fd;
  size_t fd_num = 0;
  
  assert(dev-vhost_ops-backend_type == VHOST_BACKEND_TYPE_USER);
 @@ -212,14 +214,17 @@ static int vhost_user_call(struct vhost_dev *dev, 
 unsigned long int request,
  break;
  
  case VHOST_SET_MEM_TABLE:
 -QTAILQ_FOREACH(block, ram_list.blocks, next)
 -{
 -if (block-fd  0) {
 -msg.memory.regions[fd_num].userspace_addr =
 -(uintptr_t) block-host;
 -msg.memory.regions[fd_num].memory_size = block-length;
 -msg.memory.regions[fd_num].guest_phys_addr = block-offset;
 -fds[fd_num++] = block-fd;
 +for (i = 0; i  dev-mem-nregions; ++i) {
 +struct vhost_memory_region *reg = dev-mem-regions + i;
 +fd = qemu_get_ram_fd(reg-guest_phys_addr);
 +if (fd  0) {
 +msg.memory.regions[fd_num].userspace_addr = 
 reg-userspace_addr;
 +msg.memory.regions[fd_num].memory_size  = reg-memory_size;
 +msg.memory.regions[fd_num].guest_phys_addr = 
 reg-guest_phys_addr;
 +msg.memory.regions[fd_num].mmap_offset = reg-userspace_addr 
 -
 +(uintptr_t) 
 

Re: [Qemu-devel] core dump with drive-mirror

2014-07-01 Thread Stefan Hajnoczi
On Mon, Jun 30, 2014 at 05:40:16PM -0600, Eric Blake wrote:
 On 06/30/2014 05:16 PM, Eric Blake wrote:
  I'm trying to track down a core dump with the QMP drive-mirror command.
 
 Looks like the bug is related to a base image that is not a multiple of
 a cluster size.
 
  
  # in one terminal:
  cd /tmp
  rm -f base.img snap1.img snap2.img copy.img
  
  # base.img - snap1.img - snap2.img; intentionally populating base.img
  # with a qcow2 header, but treating it as raw data
  qemu-img create -f qcow2 base.img 10M
 
 If, right here, I inject:
 
 truncate --size 262144 base.img
 
  qemu-img create -f qcow2 -b base.img -o backing_fmt=raw snap1.img
  qemu-img create -f qcow2 -b snap1.img -o backing_fmt=qcow2 snap2.img
  cp base.img copy.img
  # Yes, this command line is derived from libvirt...
  LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin \
   QEMU_AUDIO_DRV=none gdb --args  /usr/bin/qemu-system-x86_64 \
 
 ...then everything else succeeds.  So it seems the problem is that qemu
 is doing a lousy job of handling a backing file and/or destination file
 that is not fully rounded out to a proper size.

Thanks for reporting this.  It's something we need to fix during the
QEMU 2.1 hard freeze that is starting today.

Stefan


pgpiWh241inHL.pgp
Description: PGP signature


Re: [Qemu-devel] [PATCH for-2.1] block/cow: Avoid use of uninitialized cow_bs in error path

2014-07-01 Thread Stefan Hajnoczi
On Mon, Jun 30, 2014 at 07:03:37PM +0100, Peter Maydell wrote:
 Commit 25814e8987 introduced an error-exit code path which does
 a goto exit before the cow_bs variable is initialized, meaning
 we would call bdrv_unref() on an uninitialized variable and
 likely segfault. Fix this by moving the NULL-initialization
 to the top of the function and making the exit code path handle
 the case where it is NULL.
 
 Signed-off-by: Peter Maydell peter.mayd...@linaro.org
 ---
  block/cow.c | 7 ---
  1 file changed, 4 insertions(+), 3 deletions(-)

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan


pgpukdcZBO2gH.pgp
Description: PGP signature


Re: [Qemu-devel] [PATCH] qapi: Change back sector-count to sectors-count in quorum QAPI events.

2014-07-01 Thread Stefan Hajnoczi
On Mon, Jun 30, 2014 at 05:05:41PM +0200, Benoît Canet wrote:
 fe069d9d had aligned code and documentation while dropping the s from the
 actual JSON output. Fix that.
 
 This also fix test/qemu-iotest/081 since the missing s was causing a 
 permutation.
 
 Signed-off-by: Benoit Canet ben...@irqsave.net
 ---
  docs/qmp/qmp-events.txt | 26 +-
  qapi/event.json |  8 
  2 files changed, 17 insertions(+), 17 deletions(-)

Fixes qemu-iotests 081.

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan


pgpmkTQ7JBi42.pgp
Description: PGP signature


Re: [Qemu-devel] [PATCH v2] qemu-iotests: Disable Quorum testing in 041 when Quorum is not builtin

2014-07-01 Thread Stefan Hajnoczi
On Mon, Jun 30, 2014 at 04:25:47PM +0200, Benoît Canet wrote:
 The Monday 30 Jun 2014 à 16:09:57 (+0200), Stefan Hajnoczi wrote :
  On Fri, Jun 27, 2014 at 10:17:16PM +0200, Benoît Canet wrote:
  I think this patch can be boiled down to 2 lines:
  
   if __name__ == '__main__':
  +if 'quorum' not in iotests.qemu_img('--help'):
  +iotests.notrun('not built with quorum support')
   iotests.main(supported_fmts=['qcow2', 'qed'])
  
  What do you think?
 
 The detection part could work using qemu_img_pipe.

You're right, I used the wrong function.  We need the stdout.

 Are we sure that the test won't fail in strange ways like
 when using skipTest ?

Not sure what you mean.

 If so do you want me to respin this patch with your version ?

Yes, please.


pgpCtShTybM5v.pgp
Description: PGP signature


[Qemu-devel] [PATCH fix for 2.1 v2] makefile: Fix tools compile

2014-07-01 Thread Alexey Kardashevskiy
The existing test whether -lm needs to be included or not is
insufficient as it reports false negative on Fedora20/ppc64.
This happens because sin(0.0) is a constant value which compiler
can safely throw away and therefore there is no need to add -lm.
As the result, qemu-nbd/qemu-io/qemu-img tools cannot compile.

This adds a global variable and uses it in the test to prevent
from optimization.

Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru

---
Changes:
v2:
* previous s/sin/log/ replacement removed, a global variable is
used instead
---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index 23ecb37..6dd44a9 100755
--- a/configure
+++ b/configure
@@ -3453,7 +3453,7 @@ fi
 # Do we need libm
 cat  $TMPC  EOF
 #include math.h
-int main(void) { return isnan(sin(0.0)); }
+double x; int main(void) {return isnan(sin(x));}
 EOF
 if compile_prog   ; then
   :
-- 
2.0.0




Re: [Qemu-devel] [PATCH v8 03/14] qcow2: Optimize bdrv_make_empty()

2014-07-01 Thread Hu Tao
On Mon, Jun 30, 2014 at 01:33:39PM +0200, Kevin Wolf wrote:
 Am 07.06.2014 um 20:51 hat Max Reitz geschrieben:
  bdrv_make_empty() is currently only called if the current image
  represents an external snapshot that has been committed to its base
  image; it is therefore unlikely to have internal snapshots. In this
  case, bdrv_make_empty() can be greatly sped up by creating an empty L1
  table and dropping all data clusters at once by recreating the refcount
  structure accordingly instead of normally discarding all clusters.
  
  If there are snapshots, fall back to the simple implementation (discard
  all clusters).
  
  Signed-off-by: Max Reitz mre...@redhat.com
  Reviewed-by: Eric Blake ebl...@redhat.com
 
 This approach looks a bit too complicated to me, and calulating the
 required metadata size seems error-prone.
 
 How about this:
 
 1. Set the dirty flag in the header so we can mess with the L1 table
without keeping the refcounts consistent
 
 2. Overwrite the L1 table with zeros
 
 3. Overwrite the first n clusters after the header with zeros
(n = 2 + l1_clusters).
 
 4. Update the header:
refcount_table_offset = cluster_size
refcount_table_clusters = 1
l1_table_offset = 3 * cluster_size
 
 6. bdrv_truncate to n + 1 clusters
 
 7. Now update the first 8 bytes at cluster_size (the first new refcount
table entry) to point to 2 * cluster_size (new refcount block)
 
 8. Reset refcount block and L2 cache
 
 9. Allocate n + 1 clusters (the header, too) and make sure you get
offset 0
 
 10. Remove the dirty flag
 
 Surprisingly (or not) this is much like an ordinary image creation. The
 main difference is that we keep the full size of the L1 table so the
 image stays always valid (the spec would even allow us to temporarily
 set l1_size = 0, but qcow2_open() doesn't seem to like that) and all
 areas where the L1 table could be are zeroed (this includes the new
 refcount table/block until the header is updated).

Kevin,

It seems that this approach doesn't need calculation of metadata
size(minimal_blob_size()), which is exactly the one prealllocation=full
will depend on.

 
 
 I wanted to check whether this would still give the preallocation=full
 series what it needs, but a v11 doesn't seem to be on the list yet and
 v10 doesn't have the dependency on this series yet.

Although I'm now have v11 done, I'm not sure it's ready to post since
you rejected the calculation of metadata size. But for you to check how
the series depends on this patch, I uploaded it to github at
https://github.com/taohu/qemu/commits/preallocation-v11.
(specifically, the dependency exists on commit
https://github.com/taohu/qemu/commit/308720c6b10166d60045c81a4d9fab7205c85986)

If you think it's not a problem to post v11, just tell me and I can post
to list.

Regards,
Hu



Re: [Qemu-devel] Why devfn will be -1

2014-07-01 Thread Jan Kiszka
Hi Le,

On 2014-07-01 04:34, Le Tan wrote:
 Hi Jan,
 I use pci_setup_iommu() to setup a PCIIOMMUFunc for the q35 pci bus.
 In the iommu_fn, I print out the devfn parameter and find out that it
 sometimes will be -1. So what does it mean?
 The detail code is here:
 
 In mch_init() function, I write like this:
 PCIBus *pci_bus = PCI_BUS(qdev_get_parent_bus(DEVICE(mch)));
 pci_setup_iommu(pci_bus, q35_host_dma_iommu, mch-iommu);
 
 And in q35_host_dma_iommu(PCIBus *bus, void *opaque, int devfn), I
 print out the devfn parameter, sometimes it will be -1.

Hmm, I have no idea about the reason and would suggest to set a
conditional breakpoint on this function, then print the backtrace to see
where this comes from and analyze the device structure from where that
-1 was most probably taken.

Jan




signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH fix for 2.1 v2] makefile: Fix tools compile

2014-07-01 Thread Paolo Bonzini

Il 01/07/2014 09:30, Alexey Kardashevskiy ha scritto:

The existing test whether -lm needs to be included or not is
insufficient as it reports false negative on Fedora20/ppc64.
This happens because sin(0.0) is a constant value which compiler
can safely throw away and therefore there is no need to add -lm.
As the result, qemu-nbd/qemu-io/qemu-img tools cannot compile.

This adds a global variable and uses it in the test to prevent
from optimization.

Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru

---
Changes:
v2:
* previous s/sin/log/ replacement removed, a global variable is
used instead
---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index 23ecb37..6dd44a9 100755
--- a/configure
+++ b/configure
@@ -3453,7 +3453,7 @@ fi
 # Do we need libm
 cat  $TMPC  EOF
 #include math.h
-int main(void) { return isnan(sin(0.0)); }
+double x; int main(void) {return isnan(sin(x));}
 EOF
 if compile_prog   ; then
   :



Can you please test with this hunk on top:

diff --git a/Makefile.target b/Makefile.target
index 6089d29..137d0b0 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -163,10 +163,6 @@ dummy := $(call unnest-vars,.., \
 all-obj-y += $(common-obj-y)
 all-obj-$(CONFIG_SOFTMMU) += $(block-obj-y)

-ifndef CONFIG_HAIKU
-LIBS+=-lm
-endif
-
 # build either PROG or PROGW
 $(QEMU_PROG_BUILD): $(all-obj-y) ../libqemuutil.a ../libqemustub.a
$(call LINK,$^)

It should now be unnecessary.

Paolo



Re: [Qemu-devel] [PATCH fix for 2.1 v2] makefile: Fix tools compile

2014-07-01 Thread Alexey Kardashevskiy
On 07/01/2014 05:41 PM, Paolo Bonzini wrote:
 Il 01/07/2014 09:30, Alexey Kardashevskiy ha scritto:
 The existing test whether -lm needs to be included or not is
 insufficient as it reports false negative on Fedora20/ppc64.
 This happens because sin(0.0) is a constant value which compiler
 can safely throw away and therefore there is no need to add -lm.
 As the result, qemu-nbd/qemu-io/qemu-img tools cannot compile.

 This adds a global variable and uses it in the test to prevent
 from optimization.

 Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru

 ---
 Changes:
 v2:
 * previous s/sin/log/ replacement removed, a global variable is
 used instead
 ---
  configure | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/configure b/configure
 index 23ecb37..6dd44a9 100755
 --- a/configure
 +++ b/configure
 @@ -3453,7 +3453,7 @@ fi
  # Do we need libm
  cat  $TMPC  EOF
  #include math.h
 -int main(void) { return isnan(sin(0.0)); }
 +double x; int main(void) {return isnan(sin(x));}
  EOF
  if compile_prog   ; then
:

 
 Can you please test with this hunk on top:
 
 diff --git a/Makefile.target b/Makefile.target
 index 6089d29..137d0b0 100644
 --- a/Makefile.target
 +++ b/Makefile.target
 @@ -163,10 +163,6 @@ dummy := $(call unnest-vars,.., \
  all-obj-y += $(common-obj-y)
  all-obj-$(CONFIG_SOFTMMU) += $(block-obj-y)
 
 -ifndef CONFIG_HAIKU
 -LIBS+=-lm
 -endif
 -
  # build either PROG or PROGW
  $(QEMU_PROG_BUILD): $(all-obj-y) ../libqemuutil.a ../libqemustub.a
  $(call LINK,$^)
 
 It should now be unnecessary.


Tried, all good.


-- 
Alexey



Re: [Qemu-devel] [RFC PATCH V3 6/6] monitor: Add drift info to 'info jit'

2014-07-01 Thread Frederic Konrad

On 30/06/2014 15:59, Sebastian Tanase wrote:

Show in 'info jit' the current delay between the host clock
and the guest clock. In addition, print the maximum advance
and delay of the guest compared to the host.

Signed-off-by: Sebastian Tanase sebastian.tan...@openwide.fr
Tested-by: Camille Bégué camille.be...@openwide.fr
---
  cpu-exec.c| 61 +++
  cpus.c| 17 ++
  include/qemu-common.h |  5 +
  monitor.c |  1 +
  4 files changed, 65 insertions(+), 19 deletions(-)

diff --git a/cpu-exec.c b/cpu-exec.c
index 4a4533d..06809f2 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -104,25 +104,18 @@ static void init_delay_params(SyncClocks *sc,
int64_t realtime_clock_value,
const CPUState *cpu)
  {
-static int64_t clocks_offset = -1;
-int64_t virtual_clock_value;
  if (!icount_align_option) {
  return;
  }
-/* On x86 target architecture, the PIT reset function (called
-   by qemu_system_reset) will end up calling qemu_clock_warp
-   and then icount_warp_rt changing vm_clock_warp_start from 0 (initial
-   value) to -1. This in turn will make us skip the initial offset
-   between the real and virtual clocks (initially virtual clock is 0).
-   Therefore we impose that the first time we run the cpu
-   the host and virtual clocks should be aligned; we don't alter any of
-   the clocks, we just calculate the difference between them. */
-virtual_clock_value = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
-if (clocks_offset == -1) {
-clocks_offset = realtime_clock_value - virtual_clock_value;
-}
-sc-diff_clk = virtual_clock_value - realtime_clock_value + clocks_offset;
+sc-diff_clk = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) -
+   realtime_clock_value + clocks_offset;
  sc-original_instr_counter = cpu-icount_extra + cpu-icount_decr.u16.low;
+if (sc-diff_clk  max_delay) {
+max_delay = sc-diff_clk;
+}
+if (sc-diff_clk  max_advance) {
+max_advance = sc-diff_clk;
+}
  }
  static void print_delay(InformDelay *indl, int64_t diff_clk)
  {
@@ -160,10 +153,32 @@ static void init_inform(InformDelay *indl, int64_t 
realtime_clock_value)
  
  static void compute_value_of_rtc(int64_t *realtime_clock_value)

  {
-if (!icount_align_option) {
-return;
+/* When using align, we use every time the value of the host clock
+   whereas when not using align, we only need it once to calculate
+   the offset between the host and virtual clocks. We then use this
+   value to correctly print the delay between the 2 clocks when using
+   info jit in the monitor. */
+if (icount_align_option) {
+*realtime_clock_value = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
+} else if (*realtime_clock_value == 0) {
+*realtime_clock_value = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
+}

Why not || both if as they finally do the same thing?

Fred


+}
+
+static void compute_clocks_offset(int64_t realtime_clock_value)
+{
+/* On x86 target architecture, the PIT reset function (called
+   by qemu_system_reset) will end up calling qemu_clock_warp
+   and then icount_warp_rt changing vm_clock_warp_start from 0 (initial
+   value) to -1. This in turn will make us skip the initial offset
+   between the real and virtual clocks (initially virtual clock is 0).
+   Therefore we suppose that the first time we run the cpu
+   the host and virtual clocks should be aligned; we don't alter any of
+   the clocks, we just calculate the difference between them. */
+if (clocks_offset == -1) {
+clocks_offset = realtime_clock_value -
+qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
  }
-*realtime_clock_value = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
  }
  #else
  /* We don't use the align feature for User emulation
@@ -189,6 +204,10 @@ static void init_inform(InformDelay *indl, int64_t 
realtime_clock_value)
  static void compute_value_of_rtc(int64_t *realtime_clock_value)
  {
  }
+
+static void compute_clocks_offset(int64_t realtime_clock_value)
+{
+}
  #endif /* CONFIG USER ONLY */
  
  void cpu_loop_exit(CPUState *cpu)

@@ -396,7 +415,7 @@ int cpu_exec(CPUArchState *env)
  uint8_t *tc_ptr;
  uintptr_t next_tb;
  /* Delay algorithm */
-int64_t realtime_clock_value;
+static int64_t realtime_clock_value;
  static SyncClocks sc = {
  .init_delay = init_delay_params,
  .perform_align = align_clocks
@@ -465,6 +484,10 @@ int cpu_exec(CPUArchState *env)
  /* Calculating the realtime is expensive so we do it once here
 and then pass this value around. */
  compute_value_of_rtc(realtime_clock_value);
+/* We calculate the clocks_offset here, the very first time
+   we run the cpu; we do it here because it gives us the best
+ 

[Qemu-devel] [PATCH v8 for 2.1 4/4] block: add QAPI command to allow live backing file change

2014-07-01 Thread Stefan Hajnoczi
From: Jeff Cody jc...@redhat.com

This allows a user to make a live change to the backing file recorded in
an open image.

The image file to modify can be specified 2 ways:

1) image filename
2) image node-name

Note: this does not cause the backing file itself to be reopened; it
merely changes the backing filename in the image file structure, and
in internal BDS structures.

It is the responsibility of the user to pass a filename string that
can be resolved when the image chain is reopened, and the filename
string is not validated.

A good analogy for this command is that it is a live version of
'qemu-img rebase -u', with respect to changing the backing file string.

[Jeff is offline so I respun this patch in his absence.  Dropped image
filename since using node-name is preferred and this is a new command.
No need to introduce the limitations of finding images by filename.
--Stefan]

Reviewed-by: Eric Blake ebl...@redhat.com
Signed-off-by: Jeff Cody jc...@redhat.com
Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
---
 blockdev.c   | 79 
 qapi/block-core.json | 26 +
 qmp-commands.hx  | 39 ++
 3 files changed, 144 insertions(+)

diff --git a/blockdev.c b/blockdev.c
index dae92bb..48bd9a3 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2388,6 +2388,85 @@ void qmp_block_job_complete(const char *device, Error 
**errp)
 block_job_complete(job, errp);
 }
 
+void qmp_change_backing_file(const char *device,
+ const char *image_node_name,
+ const char *backing_file,
+ Error **errp)
+{
+BlockDriverState *bs = NULL;
+BlockDriverState *image_bs = NULL;
+Error *local_err = NULL;
+bool ro;
+int open_flags;
+int ret;
+
+/* find the top layer BDS of the chain */
+bs = bdrv_find(device);
+if (!bs) {
+error_set(errp, QERR_DEVICE_NOT_FOUND, device);
+return;
+}
+
+image_bs = bdrv_lookup_bs(NULL, image_node_name, local_err);
+if (local_err) {
+error_propagate(errp, local_err);
+return;
+}
+
+if (!image_bs) {
+error_setg(errp, image file not found);
+return;
+}
+
+if (bdrv_find_base(image_bs) == image_bs) {
+error_setg(errp, not allowing backing file change on an image 
+ without a backing file);
+return;
+}
+
+/* even though we are not necessarily operating on bs, we need it to
+ * determine if block ops are currently prohibited on the chain */
+if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_CHANGE, errp)) {
+return;
+}
+
+/* final sanity check */
+if (!bdrv_chain_contains(bs, image_bs)) {
+error_setg(errp, '%s' and image file are not in the same chain,
+   device);
+return;
+}
+
+/* if not r/w, reopen to make r/w */
+open_flags = image_bs-open_flags;
+ro = bdrv_is_read_only(image_bs);
+
+if (ro) {
+bdrv_reopen(image_bs, open_flags | BDRV_O_RDWR, local_err);
+if (local_err) {
+error_propagate(errp, local_err);
+return;
+}
+}
+
+ret = bdrv_change_backing_file(image_bs, backing_file,
+   image_bs-drv ? image_bs-drv-format_name : 
);
+
+if (ret  0) {
+error_setg_errno(errp, -ret, Could not change backing file to '%s',
+ backing_file);
+/* don't exit here, so we can try to restore open flags if
+ * appropriate */
+}
+
+if (ro) {
+bdrv_reopen(image_bs, open_flags, local_err);
+if (local_err) {
+error_propagate(errp, local_err); /* will preserve prior errp */
+}
+}
+}
+
 void qmp_blockdev_add(BlockdevOptions *options, Error **errp)
 {
 QmpOutputVisitor *ov = qmp_output_visitor_new();
diff --git a/qapi/block-core.json b/qapi/block-core.json
index c241967..e378653 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -680,6 +680,32 @@
   'data': 'BlockdevSnapshot' }
 
 ##
+# @change-backing-file
+#
+# Change the backing file in the image file metadata.  This does not
+# cause QEMU to reopen the image file to reparse the backing filename
+# (it may, however, perform a reopen to change permissions from
+# r/o - r/w - r/o, if needed). The new backing file string is written
+# into the image file metadata, and the QEMU internal strings are
+# updated.
+#
+# @image-node-name: The name of the block driver state node of the
+#   image to modify.
+#
+# @device:  The name of the device that owns image-node-name.
+#
+# @backing-file:The string to write as the backing file.  This
+#   string is not validated, so care should be taken
+#   when specifying the string or the image chain may
+#   not be able to be reopened again.
+#
+# Since: 2.1
+##
+{ 

[Qemu-devel] [PATCH v2 0/3] linux-aio: introduce submit I/O at batch

2014-07-01 Thread Ming Lei
Hi,

The commit 580b6b2aa2(dataplane: use the QEMU block layer for I/O)
introduces ~40% throughput regression on virtio-blk dataplane, and
one of causes is that submitting I/O at batch is removed.

This patchset trys to introduce this mechanism on block, at least,
linux-aio can benefit from that.

With these patches, it is observed that thoughout on virtio-blk
dataplane can be improved a lot, see data in commit log of patch
3/3.

It should be possible to apply the batch mechanism to other devices
(such as virtio-scsi) too.

V2:
- define return value of bdrv_io_unplug as void, suggested by Paolo
- avoid busy-wait for handling io_submit
V1:
- move queuing io stuff into linux-aio.c as suggested by Paolo


Thanks,
--
Ming Lei




[Qemu-devel] [PATCH v2 1/3] block: block: introduce bdrv_io_plug() and bdrv_io_unplug()

2014-07-01 Thread Ming Lei
This patch introduces these two APIs so that following
patches can support queuing I/O requests and submitting them
at batch for improving I/O performance.

Reviewed-by: Paolo Bonzini pbonz...@redhat.com
Signed-off-by: Ming Lei ming@canonical.com
---
 block.c   |   21 +
 include/block/block.h |3 +++
 include/block/block_int.h |4 
 3 files changed, 28 insertions(+)

diff --git a/block.c b/block.c
index 217f523..fea9e43 100644
--- a/block.c
+++ b/block.c
@@ -1910,6 +1910,7 @@ void bdrv_drain_all(void)
 bool bs_busy;
 
 aio_context_acquire(aio_context);
+bdrv_io_unplug(bs);
 bdrv_start_throttled_reqs(bs);
 bs_busy = bdrv_requests_pending(bs);
 bs_busy |= aio_poll(aio_context, bs_busy);
@@ -5774,3 +5775,23 @@ bool bdrv_is_first_non_filter(BlockDriverState 
*candidate)
 
 return false;
 }
+
+void bdrv_io_plug(BlockDriverState *bs)
+{
+BlockDriver *drv = bs-drv;
+if (drv  drv-bdrv_io_plug) {
+drv-bdrv_io_plug(bs);
+} else if (bs-file) {
+bdrv_io_plug(bs-file);
+}
+}
+
+void bdrv_io_unplug(BlockDriverState *bs)
+{
+BlockDriver *drv = bs-drv;
+if (drv  drv-bdrv_io_unplug) {
+drv-bdrv_io_unplug(bs);
+} else if (bs-file) {
+bdrv_io_unplug(bs-file);
+}
+}
diff --git a/include/block/block.h b/include/block/block.h
index d0baf4f..ea627d2 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -578,4 +578,7 @@ AioContext *bdrv_get_aio_context(BlockDriverState *bs);
  */
 void bdrv_set_aio_context(BlockDriverState *bs, AioContext *new_context);
 
+void bdrv_io_plug(BlockDriverState *bs);
+void bdrv_io_unplug(BlockDriverState *bs);
+
 #endif
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 715c761..0d75ca6 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -257,6 +257,10 @@ struct BlockDriver {
 void (*bdrv_attach_aio_context)(BlockDriverState *bs,
 AioContext *new_context);
 
+/* io queue for linux-aio */
+void (*bdrv_io_plug)(BlockDriverState *bs);
+void (*bdrv_io_unplug)(BlockDriverState *bs);
+
 QLIST_ENTRY(BlockDriver) list;
 };
 
-- 
1.7.9.5




[Qemu-devel] [PATCH v2 2/3] linux-aio: implement io plug and unplug

2014-07-01 Thread Ming Lei
This patch implements .bdrv_io_plug and .bdrv_io_unplug
callbacks for linux-aio Block Drivers, so that submitting
I/O at batch can be supported on linux-aio.

Signed-off-by: Ming Lei ming@canonical.com
---
 block/linux-aio.c |   86 +++--
 block/raw-aio.h   |2 ++
 block/raw-posix.c |   30 +++
 3 files changed, 116 insertions(+), 2 deletions(-)

diff --git a/block/linux-aio.c b/block/linux-aio.c
index f0a2c08..195f0e3 100644
--- a/block/linux-aio.c
+++ b/block/linux-aio.c
@@ -25,6 +25,8 @@
  */
 #define MAX_EVENTS 128
 
+#define MAX_QUEUED_IO  128
+
 struct qemu_laiocb {
 BlockDriverAIOCB common;
 struct qemu_laio_state *ctx;
@@ -36,9 +38,19 @@ struct qemu_laiocb {
 QLIST_ENTRY(qemu_laiocb) node;
 };
 
+struct laio_queue {
+struct iocb *iocbs[MAX_QUEUED_IO];
+bool plugged;
+unsigned int size;
+unsigned int idx;
+};
+
 struct qemu_laio_state {
 io_context_t ctx;
 EventNotifier e;
+
+/* io queue for submit at batch */
+struct laio_queue io_q;
 };
 
 static inline ssize_t io_event_ret(struct io_event *ev)
@@ -135,6 +147,70 @@ static const AIOCBInfo laio_aiocb_info = {
 .cancel = laio_cancel,
 };
 
+static void ioq_init(struct laio_queue *io_q)
+{
+io_q-size = MAX_QUEUED_IO;
+io_q-idx = 0;
+io_q-plugged = false;
+}
+
+static int ioq_submit(struct qemu_laio_state *s)
+{
+int ret, i = 0;
+int len = s-io_q.idx;
+
+do {
+ret = io_submit(s-ctx, len, s-io_q.iocbs);
+} while (i++  3  ret == -EAGAIN);
+
+/* empty io queue */
+s-io_q.idx = 0;
+
+if (ret = 0)
+  return 0;
+
+for (i = 0; i  len; i++) {
+struct qemu_laiocb *laiocb =
+container_of(s-io_q.iocbs[i], struct qemu_laiocb, iocb);
+
+laiocb-ret = ret;
+qemu_laio_process_completion(s, laiocb);
+}
+return ret;
+}
+
+static void ioq_enqueue(struct qemu_laio_state *s, struct iocb *iocb)
+{
+unsigned int idx = s-io_q.idx;
+
+s-io_q.iocbs[idx++] = iocb;
+s-io_q.idx = idx;
+
+/* submit immediately if queue is full */
+if (idx == s-io_q.size)
+ioq_submit(s);
+}
+
+void laio_io_plug(BlockDriverState *bs, void *aio_ctx)
+{
+struct qemu_laio_state *s = aio_ctx;
+
+s-io_q.plugged = true;
+}
+
+int laio_io_unplug(BlockDriverState *bs, void *aio_ctx)
+{
+struct qemu_laio_state *s = aio_ctx;
+int ret = 0;
+
+if (s-io_q.idx  0) {
+ret = ioq_submit(s);
+}
+s-io_q.plugged = false;
+
+return ret;
+}
+
 BlockDriverAIOCB *laio_submit(BlockDriverState *bs, void *aio_ctx, int fd,
 int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
 BlockDriverCompletionFunc *cb, void *opaque, int type)
@@ -168,8 +244,12 @@ BlockDriverAIOCB *laio_submit(BlockDriverState *bs, void 
*aio_ctx, int fd,
 }
 io_set_eventfd(laiocb-iocb, event_notifier_get_fd(s-e));
 
-if (io_submit(s-ctx, 1, iocbs)  0)
-goto out_free_aiocb;
+if (!s-io_q.plugged) {
+if (io_submit(s-ctx, 1, iocbs)  0)
+goto out_free_aiocb;
+} else {
+ioq_enqueue(s, iocbs);
+}
 return laiocb-common;
 
 out_free_aiocb:
@@ -204,6 +284,8 @@ void *laio_init(void)
 goto out_close_efd;
 }
 
+ioq_init(s-io_q);
+
 return s;
 
 out_close_efd:
diff --git a/block/raw-aio.h b/block/raw-aio.h
index 8cf084e..ed47c3d 100644
--- a/block/raw-aio.h
+++ b/block/raw-aio.h
@@ -40,6 +40,8 @@ BlockDriverAIOCB *laio_submit(BlockDriverState *bs, void 
*aio_ctx, int fd,
 BlockDriverCompletionFunc *cb, void *opaque, int type);
 void laio_detach_aio_context(void *s, AioContext *old_context);
 void laio_attach_aio_context(void *s, AioContext *new_context);
+void laio_io_plug(BlockDriverState *bs, void *aio_ctx);
+int laio_io_unplug(BlockDriverState *bs, void *aio_ctx);
 #endif
 
 #ifdef _WIN32
diff --git a/block/raw-posix.c b/block/raw-posix.c
index dacf4fb..ce548e1 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -1054,6 +1054,26 @@ static BlockDriverAIOCB *raw_aio_submit(BlockDriverState 
*bs,
cb, opaque, type);
 }
 
+static void raw_aio_plug(BlockDriverState *bs)
+{
+#ifdef CONFIG_LINUX_AIO
+BDRVRawState *s = bs-opaque;
+if (s-use_aio) {
+laio_io_plug(bs, s-aio_ctx);
+}
+#endif
+}
+
+static void raw_aio_unplug(BlockDriverState *bs)
+{
+#ifdef CONFIG_LINUX_AIO
+BDRVRawState *s = bs-opaque;
+if (s-use_aio) {
+laio_io_unplug(bs, s-aio_ctx);
+}
+#endif
+}
+
 static BlockDriverAIOCB *raw_aio_readv(BlockDriverState *bs,
 int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
 BlockDriverCompletionFunc *cb, void *opaque)
@@ -1503,6 +1523,8 @@ static BlockDriver bdrv_file = {
 .bdrv_aio_flush = raw_aio_flush,
 .bdrv_aio_discard = raw_aio_discard,
 .bdrv_refresh_limits = raw_refresh_limits,
+.bdrv_io_plug = raw_aio_plug,
+.bdrv_io_unplug = raw_aio_unplug,
 
 

[Qemu-devel] [PATCH v2 3/3] dataplane: submit I/O at batch

2014-07-01 Thread Ming Lei
Before commit 580b6b2aa2(dataplane: use the Qemu block
layer for I/O), dataplane for virtio-blk submits block
I/O at batch.

This commit 580b6b2aa2 replaces the custom linux AIO
implementation(including I/O batch) with Qemu block
layer, but this commit causes ~40% throughput regression
on virtio-blk performance, and removing submitting I/O
at batch is one of the cause.

This patch applys the new introduced bdrv_io_plug() and
bdrv_io_unplug() interfaces to support submitting I/O
at batch for Qemu block layer, and in my test, the change
can improve thoughput by ~30% with 'aio=native'.

Following my fio test script:

[global]
direct=1
size=4G
bsrange=4k-4k
timeout=40
numjobs=4
ioengine=libaio
iodepth=64
filename=/dev/vdc
group_reporting=1

[f]
rw=randread

Result on one of my small machine(host: x86_64, 2cores, 4thread, guest: 4cores):
- qemu master: 59K IOPS
- qemu master with these patches: 81K IOPS
- 2.0.0 release(dataplane using custom linux aio): 104K IOPS

Reviewed-by: Paolo Bonzini pbonz...@redhat.com
Signed-off-by: Ming Lei ming@canonical.com
---
 hw/block/dataplane/virtio-blk.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
index c10b7b7..8fefcce 100644
--- a/hw/block/dataplane/virtio-blk.c
+++ b/hw/block/dataplane/virtio-blk.c
@@ -289,6 +289,7 @@ static void handle_notify(EventNotifier *e)
 int ret;
 
 event_notifier_test_and_clear(s-host_notifier);
+bdrv_io_plug(s-blk-conf.bs);
 for (;;) {
 /* Disable guest-host notifies to avoid unnecessary vmexits */
 vring_disable_notification(s-vdev, s-vring);
@@ -322,6 +323,7 @@ static void handle_notify(EventNotifier *e)
 break;
 }
 }
+bdrv_io_unplug(s-blk-conf.bs);
 }
 
 /* Context: QEMU global mutex held */
-- 
1.7.9.5




Re: [Qemu-devel] [PATCH fix for 2.1 v2] makefile: Fix tools compile

2014-07-01 Thread Paolo Bonzini

Il 01/07/2014 09:47, Alexey Kardashevskiy ha scritto:

On 07/01/2014 05:41 PM, Paolo Bonzini wrote:

Il 01/07/2014 09:30, Alexey Kardashevskiy ha scritto:

The existing test whether -lm needs to be included or not is
insufficient as it reports false negative on Fedora20/ppc64.
This happens because sin(0.0) is a constant value which compiler
can safely throw away and therefore there is no need to add -lm.
As the result, qemu-nbd/qemu-io/qemu-img tools cannot compile.

This adds a global variable and uses it in the test to prevent
from optimization.

Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru

---
Changes:
v2:
* previous s/sin/log/ replacement removed, a global variable is
used instead
---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index 23ecb37..6dd44a9 100755
--- a/configure
+++ b/configure
@@ -3453,7 +3453,7 @@ fi
 # Do we need libm
 cat  $TMPC  EOF
 #include math.h
-int main(void) { return isnan(sin(0.0)); }
+double x; int main(void) {return isnan(sin(x));}
 EOF
 if compile_prog   ; then
   :



Can you please test with this hunk on top:

diff --git a/Makefile.target b/Makefile.target
index 6089d29..137d0b0 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -163,10 +163,6 @@ dummy := $(call unnest-vars,.., \
 all-obj-y += $(common-obj-y)
 all-obj-$(CONFIG_SOFTMMU) += $(block-obj-y)

-ifndef CONFIG_HAIKU
-LIBS+=-lm
-endif
-
 # build either PROG or PROGW
 $(QEMU_PROG_BUILD): $(all-obj-y) ../libqemuutil.a ../libqemustub.a
 $(call LINK,$^)

It should now be unnecessary.



Tried, all good.


Thanks, applied to scsi-next.

Paolo




[Qemu-devel] The master branch qemu compiles failed.

2014-07-01 Thread ChenLiang
Hi,

Qemu compiles failed.

./configure --enable-debug  --target-list=x86_64-softmmu
make -j

net/l2tpv3.c: In function ‘net_l2tpv3_process_queue’:
net/l2tpv3.c:368: error: invalid use of undefined type ‘struct mmsghdr’
net/l2tpv3.c:369: error: dereferencing pointer to incomplete type
net/l2tpv3.c:370: error: dereferencing pointer to incomplete type
net/l2tpv3.c:371: error: dereferencing pointer to incomplete type
net/l2tpv3.c: In function ‘net_l2tpv3_send’:
net/l2tpv3.c:445: error: invalid use of undefined type ‘struct mmsghdr’
net/l2tpv3.c:448: warning: implicit declaration of function ‘recvmmsg’
net/l2tpv3.c:448: warning: nested extern declaration of ‘recvmmsg’
net/l2tpv3.c: In function ‘destroy_vector’:
net/l2tpv3.c:472: error: dereferencing pointer to incomplete type
net/l2tpv3.c:473: error: dereferencing pointer to incomplete type
net/l2tpv3.c:478: error: dereferencing pointer to incomplete type
net/l2tpv3.c:480: error: increment of pointer to unknown structure
net/l2tpv3.c:480: error: arithmetic on pointer to an incomplete type
net/l2tpv3.c: In function ‘build_l2tpv3_vector’:
net/l2tpv3.c:492: error: invalid application of ‘sizeof’ to incomplete type 
‘struct mmsghdr’
net/l2tpv3.c:495: error: dereferencing pointer to incomplete type
net/l2tpv3.c:496: error: dereferencing pointer to incomplete type
net/l2tpv3.c:498: error: dereferencing pointer to incomplete type
net/l2tpv3.c:504: error: dereferencing pointer to incomplete type
net/l2tpv3.c:505: error: dereferencing pointer to incomplete type
net/l2tpv3.c:506: error: dereferencing pointer to incomplete type
net/l2tpv3.c:507: error: dereferencing pointer to incomplete type
net/l2tpv3.c:508: error: increment of pointer to unknown structure
net/l2tpv3.c:508: error: arithmetic on pointer to an incomplete type


Best regards
Chenliang




Re: [Qemu-devel] [PATCH v2] qemu-iotests: Disable Quorum testing in 041 when Quorum is not builtin

2014-07-01 Thread Kevin Wolf
Am 30.06.2014 um 16:09 hat Stefan Hajnoczi geschrieben:
 On Fri, Jun 27, 2014 at 10:17:16PM +0200, Benoît Canet wrote:
 I think this patch can be boiled down to 2 lines:
 
  if __name__ == '__main__':
 +if 'quorum' not in iotests.qemu_img('--help'):
 +iotests.notrun('not built with quorum support')
  iotests.main(supported_fmts=['qcow2', 'qed'])
 
 What do you think?

That would disable the whole test case 041, whereas Benoît's patch
only disables the quorum-related part. (The test case is really about
migration, not only quorum.)

Kevin


pgpJsT4n9port.pgp
Description: PGP signature


Re: [Qemu-devel] [PATCH v4 02/33] target-arm: move Aarch32 SCR into security reglist

2014-07-01 Thread Edgar E. Iglesias
On Mon, Jun 30, 2014 at 06:09:02PM -0500, greg.bell...@linaro.org wrote:
 From: Fabian Aggeler aggel...@ethz.ch
 
 Define a new ARM CP register info list for the ARMv7 Security Extension
 feature. Register that list only for ARM cores with Security Extension/EL3
 support. Moving Aarch32 SCR into Security Extension register group.
 
 Signed-off-by: Sergey Fedorov s.fedo...@samsung.com
 Signed-off-by: Fabian Aggeler aggel...@ethz.ch
 Signed-off-by: Greg Bellows greg.bell...@linaro.org

Reviewed-by: Edgar E. Iglesias edgar.igles...@xilinx.com



 
 --
 v3 - v4
 - Renamed security_cp_reginfo to v7_el3_cp_reginfo
 - Conditionalized define on whether v7 or v8 were enabled
 
 Signed-off-by: Greg Bellows greg.bell...@linaro.org
 ---
  target-arm/helper.c | 17 +
  1 file changed, 13 insertions(+), 4 deletions(-)
 
 diff --git a/target-arm/helper.c b/target-arm/helper.c
 index 7c4b801..1ea30fe 100644
 --- a/target-arm/helper.c
 +++ b/target-arm/helper.c
 @@ -792,9 +792,6 @@ static const ARMCPRegInfo v7_cp_reginfo[] = {
.access = PL1_RW, .writefn = vbar_write,
.fieldoffset = offsetof(CPUARMState, cp15.vbar_el[1]),
.resetvalue = 0 },
 -{ .name = SCR, .cp = 15, .crn = 1, .crm = 1, .opc1 = 0, .opc2 = 0,
 -  .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.c1_scr),
 -  .resetvalue = 0, },
  { .name = CCSIDR, .state = ARM_CP_STATE_BOTH,
.opc0 = 3, .crn = 0, .crm = 0, .opc1 = 1, .opc2 = 0,
.access = PL1_R, .readfn = ccsidr_read, .type = ARM_CP_NO_MIGRATE },
 @@ -2227,6 +2224,13 @@ static const ARMCPRegInfo v8_el3_cp_reginfo[] = {
  REGINFO_SENTINEL
  };
  
 +static const ARMCPRegInfo v7_el3_cp_reginfo[] = {
 +{ .name = SCR, .cp = 15, .crn = 1, .crm = 1, .opc1 = 0, .opc2 = 0,
 +  .access = PL3_RW, .fieldoffset = offsetof(CPUARMState, cp15.scr_el3),
 +  .resetvalue = 0, },
 +REGINFO_SENTINEL
 +};
 +
  static void sctlr_write(CPUARMState *env, const ARMCPRegInfo *ri,
  uint64_t value)
  {
 @@ -2489,7 +2493,12 @@ void register_cp_regs_for_features(ARMCPU *cpu)
  }
  }
  if (arm_feature(env, ARM_FEATURE_EL3)) {
 -define_arm_cp_regs(cpu, v8_el3_cp_reginfo);
 +if (arm_feature(env, ARM_FEATURE_V8)) {
 +define_arm_cp_regs(cpu, v8_el3_cp_reginfo);
 +}
 +if (arm_feature(env, ARM_FEATURE_V7)) {
 +define_arm_cp_regs(cpu, v7_el3_cp_reginfo);
 +}
  }
  if (arm_feature(env, ARM_FEATURE_MPU)) {
  /* These are the MPU registers prior to PMSAv6. Any new
 -- 
 1.8.3.2
 



Re: [Qemu-devel] The master branch qemu compiles failed.

2014-07-01 Thread Paolo Bonzini

Il 01/07/2014 10:00, ChenLiang ha scritto:

./configure --enable-debug  --target-list=x86_64-softmmu
make -j

net/l2tpv3.c: In function ‘net_l2tpv3_process_queue’:
net/l2tpv3.c:368: error: invalid use of undefined type ‘struct mmsghdr’
net/l2tpv3.c:369: error: dereferencing pointer to incomplete type
net/l2tpv3.c:370: error: dereferencing pointer to incomplete type
net/l2tpv3.c:371: error: dereferencing pointer to incomplete type
net/l2tpv3.c: In function ‘net_l2tpv3_send’:
net/l2tpv3.c:445: error: invalid use of undefined type ‘struct mmsghdr’
net/l2tpv3.c:448: warning: implicit declaration of function ‘recvmmsg’
net/l2tpv3.c:448: warning: nested extern declaration of ‘recvmmsg’
net/l2tpv3.c: In function ‘destroy_vector’:
net/l2tpv3.c:472: error: dereferencing pointer to incomplete type
net/l2tpv3.c:473: error: dereferencing pointer to incomplete type
net/l2tpv3.c:478: error: dereferencing pointer to incomplete type
net/l2tpv3.c:480: error: increment of pointer to unknown structure
net/l2tpv3.c:480: error: arithmetic on pointer to an incomplete type
net/l2tpv3.c: In function ‘build_l2tpv3_vector’:
net/l2tpv3.c:492: error: invalid application of ‘sizeof’ to incomplete type 
‘struct mmsghdr’
net/l2tpv3.c:495: error: dereferencing pointer to incomplete type
net/l2tpv3.c:496: error: dereferencing pointer to incomplete type
net/l2tpv3.c:498: error: dereferencing pointer to incomplete type
net/l2tpv3.c:504: error: dereferencing pointer to incomplete type
net/l2tpv3.c:505: error: dereferencing pointer to incomplete type
net/l2tpv3.c:506: error: dereferencing pointer to incomplete type
net/l2tpv3.c:507: error: dereferencing pointer to incomplete type
net/l2tpv3.c:508: error: increment of pointer to unknown structure
net/l2tpv3.c:508: error: arithmetic on pointer to an incomplete type


What OS and, if Linux, what distro?

Paolo



Re: [Qemu-devel] [PATCH v4 04/33] target-arm: add arm_is_secure() function

2014-07-01 Thread Edgar E. Iglesias
On Mon, Jun 30, 2014 at 06:09:04PM -0500, greg.bell...@linaro.org wrote:
 From: Fabian Aggeler aggel...@ethz.ch
 
 arm_is_secure() function allows to determine CPU security state
 if the CPU implements Security Extensions/EL3.
 arm_is_secure_below_el3() returns true if CPU is in secure state
 below EL3.
 
 Signed-off-by: Sergey Fedorov s.fedo...@samsung.com
 Signed-off-by: Fabian Aggeler aggel...@ethz.ch
 Signed-off-by: Greg Bellows greg.bell...@linaro.org
 ---
  target-arm/cpu.h | 38 ++
  1 file changed, 38 insertions(+)
 
 diff --git a/target-arm/cpu.h b/target-arm/cpu.h
 index ffc51f2..aba077b 100644
 --- a/target-arm/cpu.h
 +++ b/target-arm/cpu.h
 @@ -726,6 +726,44 @@ static inline int arm_feature(CPUARMState *env, int 
 feature)
  return (env-features  (1ULL  feature)) != 0;
  }
  
 +
 +/* Return true if exception level below EL3 is in secure state */
 +static inline bool arm_is_secure_below_el3(CPUARMState *env)
 +{
 +#if !defined(CONFIG_USER_ONLY)
 +if (arm_feature(env, ARM_FEATURE_EL3)) {
 +return !(env-cp15.scr_el3  SCR_NS);
 +} else if (arm_feature(env, ARM_FEATURE_EL2)) {
 +return false;
 +} else {
 +/* IMPDEF: QEMU defaults to non-secure */
 +return false;
 +}
 +#else
 +return false;
 +#endif
 +}

Should we be #ifdefing the entire arm_is_secure_below_el3() as it is
not called from user-only code?



 +
 +/* Return true if the processor is in secure state */
 +static inline bool arm_is_secure(CPUARMState *env)
 +{
 +#if !defined(CONFIG_USER_ONLY)
 +if (arm_feature(env, ARM_FEATURE_EL3)) {
 +if (env-aarch64  extract32(env-pstate, 2, 2) == 3) {
 +/* CPU currently in Aarch64 state and EL3 */
 +return true;
 +} else if (!env-aarch64 
 +(env-uncached_cpsr  CPSR_M) == ARM_CPU_MODE_MON) {
 +/* CPU currently in Aarch32 state and monitor mode */
 +return true;
 +}
 +}
 +return arm_is_secure_below_el3(env);
 +#else
 +return false;
 +#endif
 +}
 +
  /* Return true if the specified exception level is running in AArch64 state. 
 */
  static inline bool arm_el_is_aa64(CPUARMState *env, int el)
  {
 -- 
 1.8.3.2
 



Re: [Qemu-devel] [PATCH fix for 2.1] makefile: Fix tools compile

2014-07-01 Thread Peter Maydell
On 1 July 2014 07:52, Paolo Bonzini pbonz...@redhat.com wrote:
 Il 01/07/2014 07:42, Alexey Kardashevskiy ha scritto:

 This is wrong actually. The problem here that compiler knows how to
 optimize constants. sin(0.0) is the one while log(0.0) is not (it is
 supposed to throw error or something as it the result is infinity).

 So the correct test here could be:
 int main(void) { volatile double x = 1; return isnan(sin(x)); }

 But I am afraid pretty soon compilers will learn how to optimize this as
 well :)


 I think something like double x; int f(void) {return isnan(sin(x));}
 should be bullet proof.

This is a compile_prog test, though -- the compiler could spot
that x and f are both unused, since it has the entire program
in hand. My suggestion would be:

int main(int argc, char **argv) { return isnan(sin((double)argc)); }

thanks
-- PMM



Re: [Qemu-devel] [PATCH v4 07/33] target-arm: add non-secure Translation Block flag

2014-07-01 Thread Edgar E. Iglesias
On Mon, Jun 30, 2014 at 06:09:07PM -0500, greg.bell...@linaro.org wrote:
 From: Sergey Fedorov s.fedo...@samsung.com
 
 This patch is based on idea found in patch at
 git://github.com/jowinter/qemu-trustzone.git
 f3d955c6c0ed8c46bc0eb10b634201032a651dd2 by
 Johannes Winter johannes.win...@iaik.tugraz.at.
 
 This flag prevents QEMU from executing TCG code generated for other CPU
 security state. It also allows to generate different TCG code depending on
 CPU secure state.
 
 Signed-off-by: Sergey Fedorov s.fedo...@samsung.com
 Signed-off-by: Fabian Aggeler aggel...@ethz.ch
 Signed-off-by: Greg Bellows greg.bell...@linaro.org

Reviewed-by: Edgar E. Iglesias edgar.igles...@xilinx.com


 ---
  target-arm/cpu.h   | 10 ++
  target-arm/translate-a64.c |  1 +
  target-arm/translate.c |  3 +++
  target-arm/translate.h |  1 +
  4 files changed, 15 insertions(+)
 
 diff --git a/target-arm/cpu.h b/target-arm/cpu.h
 index 1faf1e2..44e0943 100644
 --- a/target-arm/cpu.h
 +++ b/target-arm/cpu.h
 @@ -1291,6 +1291,8 @@ static inline int cpu_mmu_index (CPUARMState *env)
  #define ARM_TBFLAG_BSWAP_CODE_MASK  (1  ARM_TBFLAG_BSWAP_CODE_SHIFT)
  #define ARM_TBFLAG_CPACR_FPEN_SHIFT 17
  #define ARM_TBFLAG_CPACR_FPEN_MASK  (1  ARM_TBFLAG_CPACR_FPEN_SHIFT)
 +#define ARM_TBFLAG_NS_SHIFT 18
 +#define ARM_TBFLAG_NS_MASK  (1  ARM_TBFLAG_NS_SHIFT)
  
  /* Bit usage when in AArch64 state */
  #define ARM_TBFLAG_AA64_EL_SHIFT0
 @@ -1321,6 +1323,8 @@ static inline int cpu_mmu_index (CPUARMState *env)
  (((F)  ARM_TBFLAG_AA64_EL_MASK)  ARM_TBFLAG_AA64_EL_SHIFT)
  #define ARM_TBFLAG_AA64_FPEN(F) \
  (((F)  ARM_TBFLAG_AA64_FPEN_MASK)  ARM_TBFLAG_AA64_FPEN_SHIFT)
 +#define ARM_TBFLAG_NS(F) \
 +(((F)  ARM_TBFLAG_NS_MASK)  ARM_TBFLAG_NS_SHIFT)
  
  static inline void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc,
  target_ulong *cs_base, int *flags)
 @@ -1334,6 +1338,9 @@ static inline void cpu_get_tb_cpu_state(CPUARMState 
 *env, target_ulong *pc,
  if (fpen == 3 || (fpen == 1  arm_current_pl(env) != 0)) {
  *flags |= ARM_TBFLAG_AA64_FPEN_MASK;
  }
 +if (!arm_is_secure(env)) {
 +*flags |= ARM_TBFLAG_NS_MASK;
 +}
  } else {
  int privmode;
  *pc = env-regs[15];
 @@ -1350,6 +1357,9 @@ static inline void cpu_get_tb_cpu_state(CPUARMState 
 *env, target_ulong *pc,
  if (privmode) {
  *flags |= ARM_TBFLAG_PRIV_MASK;
  }
 +if (!arm_is_secure(env)) {
 +*flags |= ARM_TBFLAG_NS_MASK;
 +}
  if (env-vfp.xregs[ARM_VFP_FPEXC]  (1  30)
  || arm_el_is_aa64(env, 1)) {
  *flags |= ARM_TBFLAG_VFPEN_MASK;
 diff --git a/target-arm/translate-a64.c b/target-arm/translate-a64.c
 index 446d2cd..ad30903 100644
 --- a/target-arm/translate-a64.c
 +++ b/target-arm/translate-a64.c
 @@ -10879,6 +10879,7 @@ void gen_intermediate_code_internal_a64(ARMCPU *cpu,
  dc-condexec_cond = 0;
  #if !defined(CONFIG_USER_ONLY)
  dc-user = (ARM_TBFLAG_AA64_EL(tb-flags) == 0);
 +dc-ns = ARM_TBFLAG_NS(tb-flags);
  #endif
  dc-cpacr_fpen = ARM_TBFLAG_AA64_FPEN(tb-flags);
  dc-vec_len = 0;
 diff --git a/target-arm/translate.c b/target-arm/translate.c
 index cf4e767..bf17952 100644
 --- a/target-arm/translate.c
 +++ b/target-arm/translate.c
 @@ -53,8 +53,10 @@ static uint32_t gen_opc_condexec_bits[OPC_BUF_SIZE];
  
  #if defined(CONFIG_USER_ONLY)
  #define IS_USER(s) 1
 +#define IS_NS(s) 1
  #else
  #define IS_USER(s) (s-user)
 +#define IS_NS(s) (s-ns)
  #endif
  
  TCGv_ptr cpu_env;
 @@ -10904,6 +10906,7 @@ static inline void 
 gen_intermediate_code_internal(ARMCPU *cpu,
  dc-condexec_cond = ARM_TBFLAG_CONDEXEC(tb-flags)  4;
  #if !defined(CONFIG_USER_ONLY)
  dc-user = (ARM_TBFLAG_PRIV(tb-flags) == 0);
 +dc-ns = ARM_TBFLAG_NS(tb-flags);
  #endif
  dc-cpacr_fpen = ARM_TBFLAG_CPACR_FPEN(tb-flags);
  dc-vfp_enabled = ARM_TBFLAG_VFPEN(tb-flags);
 diff --git a/target-arm/translate.h b/target-arm/translate.h
 index 31a0104..6e8620a 100644
 --- a/target-arm/translate.h
 +++ b/target-arm/translate.h
 @@ -19,6 +19,7 @@ typedef struct DisasContext {
  int bswap_code;
  #if !defined(CONFIG_USER_ONLY)
  int user;
 +int ns;
  #endif
  bool cpacr_fpen; /* FP enabled via CPACR.FPEN */
  bool vfp_enabled; /* FP enabled via FPSCR.EN */
 -- 
 1.8.3.2
 



Re: [Qemu-devel] [PATCH v8 for 2.1 4/4] block: add QAPI command to allow live backing file change

2014-07-01 Thread Kevin Wolf
Am 01.07.2014 um 09:52 hat Stefan Hajnoczi geschrieben:
 From: Jeff Cody jc...@redhat.com
 
 This allows a user to make a live change to the backing file recorded in
 an open image.
 
 The image file to modify can be specified 2 ways:
 
 1) image filename
 2) image node-name
 
 Note: this does not cause the backing file itself to be reopened; it
 merely changes the backing filename in the image file structure, and
 in internal BDS structures.
 
 It is the responsibility of the user to pass a filename string that
 can be resolved when the image chain is reopened, and the filename
 string is not validated.
 
 A good analogy for this command is that it is a live version of
 'qemu-img rebase -u', with respect to changing the backing file string.
 
 [Jeff is offline so I respun this patch in his absence.  Dropped image
 filename since using node-name is preferred and this is a new command.
 No need to introduce the limitations of finding images by filename.
 --Stefan]
 
 Reviewed-by: Eric Blake ebl...@redhat.com
 Signed-off-by: Jeff Cody jc...@redhat.com
 Signed-off-by: Stefan Hajnoczi stefa...@redhat.com

Reviewed-by: Kevin Wolf kw...@redhat.com



Re: [Qemu-devel] [RFC] qemu VGA endian swap low level drawing changes

2014-07-01 Thread Gerd Hoffmann
On Mo, 2014-06-30 at 22:32 +1000, Benjamin Herrenschmidt wrote:
 On Mon, 2014-06-30 at 13:14 +0200, Gerd Hoffmann wrote:
Hi,
  
   From what I can tell, we only ever call the cursor drawing callback on
   non-shared surfaces. Should I deduce that the HW cursor emulation simply
   doesn't work when using shared surfaces ? Or is there another path I
   have missed to handle it ?
  
  Hmm.  Looks like hw-cursor-on-shared-surface broken indeed.  Need to dig
  out a guest which actually uses it  go figure when testing your patch
  series ...
 
 I don't think I broke it much more than it already was but then I
 couldn't find a guest using it. I've tried the plain cirrus DDX in X and
 it didn't have any problem... maybe windows ?

Nope.  windows xp doesn't use it.  Anything newer doesn't ship with
cirrus drivers any more (and uses vesa bios support).

Looking at the code the cirrus hardware cursor supports two colors only
(and some funky xor mode).  Guess it simply doesn't cut it as you can't
have your cursors drop shadows with that, so guests are ignoring it.

 Right. A quick fix would be to add a flag to force always using a shadow
 surface and set it in cirrus ... I'm not sure anybody will notice the
 performance difference.

I suspect we can rip out hw cursor emulation and nobody will notice the
difference either ...

cheers,
  Gerd





[Qemu-devel] [PULL for-2.1 0/3] virtio-scsi fixes, and block/iscsi compilation fix

2014-07-01 Thread Paolo Bonzini
The following changes since commit ec9fe956d5c728da770db5ec9bc429080ccb5043:

  Merge remote-tracking branch 'remotes/bonzini/small-fixes' into staging 
(2014-06-30 15:56:00 +0100)

are available in the git repository at:


  git://github.com/bonzini/qemu.git scsi-next

for you to fetch changes up to 5da65870fb1f698aab8c265c55884ca3d955276b:

  configure: Fix -lm test, so that tools can be compiled on hosts that require 
-lm (2014-07-01 09:42:59 +0200)


Alexey Kardashevskiy (1):
  configure: Fix -lm test, so that tools can be compiled on hosts that 
require -lm

Cédric Le Goater (1):
  virtio-scsi: scsi events must be converted to target endianness

Greg Kurz (1):
  virtio-scsi: virtio_scsi_push_event() lacks VirtIOSCSIReq parsing

 Makefile.target   |  4 
 configure |  2 +-
 hw/scsi/virtio-scsi.c | 12 +++-
 3 files changed, 4 insertions(+), 14 deletions(-)
-- 
1.8.3.1




[Qemu-devel] [PULL 3/3] configure: Fix -lm test, so that tools can be compiled on hosts that require -lm

2014-07-01 Thread Paolo Bonzini
From: Alexey Kardashevskiy a...@ozlabs.ru

The existing test whether -lm needs to be included or not is
insufficient as it reports false negative on Fedora20/ppc64.
This happens because sin(0.0) is a constant value which compiler
can safely throw away and therefore there is no need to add -lm.
As the result, qemu-nbd/qemu-io/qemu-img tools cannot compile.

This adds a global variable and uses it in the test to prevent
from optimization.

Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru
[Remove now useless -lm addition in Makefile.target. - Paolo]
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 Makefile.target | 4 
 configure   | 2 +-
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/Makefile.target b/Makefile.target
index 6089d29..137d0b0 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -163,10 +163,6 @@ dummy := $(call unnest-vars,.., \
 all-obj-y += $(common-obj-y)
 all-obj-$(CONFIG_SOFTMMU) += $(block-obj-y)
 
-ifndef CONFIG_HAIKU
-LIBS+=-lm
-endif
-
 # build either PROG or PROGW
 $(QEMU_PROG_BUILD): $(all-obj-y) ../libqemuutil.a ../libqemustub.a
$(call LINK,$^)
diff --git a/configure b/configure
index 23ecb37..6dd44a9 100755
--- a/configure
+++ b/configure
@@ -3453,7 +3453,7 @@ fi
 # Do we need libm
 cat  $TMPC  EOF
 #include math.h
-int main(void) { return isnan(sin(0.0)); }
+double x; int main(void) {return isnan(sin(x));}
 EOF
 if compile_prog   ; then
   :
-- 
1.8.3.1




[Qemu-devel] [PULL 2/3] virtio-scsi: scsi events must be converted to target endianness

2014-07-01 Thread Paolo Bonzini
From: Cédric Le Goater c...@fr.ibm.com

Virtio SCSI Events need to be byteswapped before being pushed
when host and guest have a different endianness. Not doing so
breaks hotplug of virtio scsi disks, with the following error
message being printed in the guest console:

virtio_scsi: Unsupport virtio scsi event 100

This issue got uncovered while testing disk hotplug with a PowerKVM
ppc64le guest. I have checked that this issue also affects a x86_64
guest run on a ppc64 host.

Signed-off-by: Cédric Le Goater c...@fr.ibm.com
[ Ported from PowerKVM,
  Greg Kurz gk...@linux.vnet.ibm.com ]
Signed-off-by: Greg Kurz gk...@linux.vnet.ibm.com
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 hw/scsi/virtio-scsi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index 3fecdca..0eb069a 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -587,8 +587,8 @@ static void virtio_scsi_push_event(VirtIOSCSI *s, 
SCSIDevice *dev,
 
 evt = req-resp.event;
 memset(evt, 0, sizeof(VirtIOSCSIEvent));
-evt-event = event;
-evt-reason = reason;
+evt-event = virtio_tswap32(vdev, event);
+evt-reason = virtio_tswap32(vdev, reason);
 if (!dev) {
 assert(event == VIRTIO_SCSI_T_EVENTS_MISSED);
 } else {
-- 
1.8.3.1





Re: [Qemu-devel] The master branch qemu compiles failed.

2014-07-01 Thread Laurent Desnogues
On Tue, Jul 1, 2014 at 10:17 AM, Paolo Bonzini pbonz...@redhat.com wrote:
 Il 01/07/2014 10:00, ChenLiang ha scritto:

 ./configure --enable-debug  --target-list=x86_64-softmmu
 make -j

 net/l2tpv3.c: In function ‘net_l2tpv3_process_queue’:
 net/l2tpv3.c:368: error: invalid use of undefined type ‘struct mmsghdr’
 net/l2tpv3.c:369: error: dereferencing pointer to incomplete type
 net/l2tpv3.c:370: error: dereferencing pointer to incomplete type
 net/l2tpv3.c:371: error: dereferencing pointer to incomplete type
 net/l2tpv3.c: In function ‘net_l2tpv3_send’:
 net/l2tpv3.c:445: error: invalid use of undefined type ‘struct mmsghdr’
 net/l2tpv3.c:448: warning: implicit declaration of function ‘recvmmsg’
 net/l2tpv3.c:448: warning: nested extern declaration of ‘recvmmsg’
 net/l2tpv3.c: In function ‘destroy_vector’:
 net/l2tpv3.c:472: error: dereferencing pointer to incomplete type
 net/l2tpv3.c:473: error: dereferencing pointer to incomplete type
 net/l2tpv3.c:478: error: dereferencing pointer to incomplete type
 net/l2tpv3.c:480: error: increment of pointer to unknown structure
 net/l2tpv3.c:480: error: arithmetic on pointer to an incomplete type
 net/l2tpv3.c: In function ‘build_l2tpv3_vector’:
 net/l2tpv3.c:492: error: invalid application of ‘sizeof’ to incomplete
 type ‘struct mmsghdr’
 net/l2tpv3.c:495: error: dereferencing pointer to incomplete type
 net/l2tpv3.c:496: error: dereferencing pointer to incomplete type
 net/l2tpv3.c:498: error: dereferencing pointer to incomplete type
 net/l2tpv3.c:504: error: dereferencing pointer to incomplete type
 net/l2tpv3.c:505: error: dereferencing pointer to incomplete type
 net/l2tpv3.c:506: error: dereferencing pointer to incomplete type
 net/l2tpv3.c:507: error: dereferencing pointer to incomplete type
 net/l2tpv3.c:508: error: increment of pointer to unknown structure
 net/l2tpv3.c:508: error: arithmetic on pointer to an incomplete type


 What OS and, if Linux, what distro?

FWIW I get these errors (and some others related to conflicting
uint64_t definitions) on this:

CentOS release 5.6 (Final)

Thanks,

Laurent


 Paolo




[Qemu-devel] [PULL 1/3] virtio-scsi: virtio_scsi_push_event() lacks VirtIOSCSIReq parsing

2014-07-01 Thread Paolo Bonzini
From: Greg Kurz gk...@linux.vnet.ibm.com

Hotplug of a virtio scsi disk is currently broken: no disk appears in the
guest (verified with a fedora 20 host running a fedora 20 guest with KVM).
Bisect leeds to Paolo's patches to support any_layout, especially this
commit:

commit 36b15c79aa1bef5fe7543f9f2629b6413720bbfb
Author: Paolo Bonzini pbonz...@redhat.com
Date:   Tue Jun 10 16:21:18 2014 +0200

virtio-scsi: start preparing for any_layout

It modifies virtio_scsi_pop_req() so that it is up to the callers to parse
the virtio scsi request. It seems that virtio_scsi_push_event() was not
modified accordingly...

This patch adds a call to virtio_scsi_parse_req(). It also drops some
sanity checks that are already performed by virtio_scsi_parse_req().

Signed-off-by: Greg Kurz gk...@linux.vnet.ibm.com
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 hw/scsi/virtio-scsi.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index 04ecfa7..3fecdca 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -565,7 +565,6 @@ static void virtio_scsi_push_event(VirtIOSCSI *s, 
SCSIDevice *dev,
 VirtIOSCSIReq *req;
 VirtIOSCSIEvent *evt;
 VirtIODevice *vdev = VIRTIO_DEVICE(s);
-int in_size;
 
 if (!(vdev-status  VIRTIO_CONFIG_S_DRIVER_OK)) {
 return;
@@ -577,17 +576,12 @@ static void virtio_scsi_push_event(VirtIOSCSI *s, 
SCSIDevice *dev,
 return;
 }
 
-if (req-elem.out_num) {
-virtio_scsi_bad_req();
-}
-
 if (s-events_dropped) {
 event |= VIRTIO_SCSI_T_EVENTS_MISSED;
 s-events_dropped = false;
 }
 
-in_size = iov_size(req-elem.in_sg, req-elem.in_num);
-if (in_size  sizeof(VirtIOSCSIEvent)) {
+if (virtio_scsi_parse_req(req, 0, sizeof(VirtIOSCSIEvent))) {
 virtio_scsi_bad_req();
 }
 
-- 
1.8.3.1





Re: [Qemu-devel] The master branch qemu compiles failed.

2014-07-01 Thread Stefan Hajnoczi
On Tue, Jul 01, 2014 at 04:00:52PM +0800, ChenLiang wrote:
 Qemu compiles failed.

What is your kernel version?

I guess you're running an old kernel without recvmmsg().  So the kernel
headers are missing the mmsghdr struct.

If you would like to contribute a patch to fix this, please introduce a
CONFIG_L2TPV3 variable in ./configure and check for mmsghdr with a small
C test that declares a variable using this struct.

Then modify net/Makefile.objs to switch l2tpv3.o from CONFIG_LINUX to
your new CONFIG_L2TPV3 variable.  This way it only gets built on hosts
that support mmsghdr.

You can find examples of other compile tests in ./configure.

If not, let us know and either I or Anton will fix this problem.

Stefan


pgp8pR5869MLG.pgp
Description: PGP signature


Re: [Qemu-devel] [PATCH v4 09/33] target-arm: extend Aarch32 async excp masking

2014-07-01 Thread Edgar E. Iglesias
On Mon, Jun 30, 2014 at 06:09:09PM -0500, greg.bell...@linaro.org wrote:
 From: Fabian Aggeler aggel...@ethz.ch
 
 This patch extends arm_excp_unmasked() according to ARM ARMv7 and
 ARM ARMv8 (all EL running in Aarch32) and adds comments.
 
 Signed-off-by: Fabian Aggeler aggel...@ethz.ch
 Signed-off-by: Greg Bellows greg.bell...@linaro.org
 ---
  target-arm/cpu.h | 77 
 
  1 file changed, 61 insertions(+), 16 deletions(-)
 
 diff --git a/target-arm/cpu.h b/target-arm/cpu.h
 index 44e0943..fbd7cad 100644
 --- a/target-arm/cpu.h
 +++ b/target-arm/cpu.h
 @@ -597,6 +597,8 @@ static inline void xpsr_write(CPUARMState *env, uint32_t 
 val, uint32_t mask)
  #define SCR_IRQ   (1U  1)
  #define SCR_FIQ   (1U  2)
  #define SCR_EA(1U  3)
 +#define SCR_FW(1U  4)
 +#define SCR_AW(1U  5)
  #define SCR_SMD   (1U  7)
  #define SCR_HCE   (1U  8)
  #define SCR_SIF   (1U  9)
 @@ -1199,30 +1201,73 @@ static inline bool arm_excp_unmasked(CPUState *cs, 
 unsigned int excp_idx)
  {
  CPUARMState *env = cs-env_ptr;
  unsigned int cur_el = arm_current_pl(env);
 -unsigned int target_el = arm_excp_target_el(cs, excp_idx);
 -/* FIXME: Use actual secure state.  */
 -bool secure = false;
 -/* Interrupts can only be hypervised and routed to
 - * EL2 if we are in NS EL0/1.
 - */
 -bool irq_can_hyp = !secure  cur_el  2  target_el == 2;
 +bool secure = arm_is_secure(env);
 +
  bool irq_unmasked = ((IS_M(env)  env-regs[15]  0xfff0)
|| !(env-daif  PSTATE_I));
  
 -/* Don't take exceptions if they target a lower EL.  */
 -if (cur_el  target_el) {
 -return false;
 -}
 -

Hi,

I think you might have missed a few of comments on the previous review.
If we remove the check for cur_el  target_el, we need to replace it
with something similar for VIRQ/VFIQ. VIRQ and VFIQ target EL1 and
cannot be taken while in EL2 or 3.

Cheers,
Edgar


 +/* ARM ARMv7 B1.8.6  Asynchronous exception masking (table B1-12/B1-13)
 + * ARM ARMv8 G1.11.3 Asynchronous exception masking controls
 + * (table G1-18/G1-19) */
  switch (excp_idx) {
  case EXCP_FIQ:
 -if (irq_can_hyp  (env-cp15.hcr_el2  HCR_FMO)) {
 -return true;
 +if (!secure) {
 +if (arm_feature(env, ARM_FEATURE_EL2) 
 +(env-cp15.hcr_el2  HCR_FMO)) {
 +/* CPSR.F/PSTATE.F ignored if
 + *  - exception is taken from Non-secure state
 + *  - HCR.FMO == 1
 + *  - either:  - not in Hyp mode
 + * - SCR.FIQ routes exception to monitor mode
 + */
 +if (cur_el  2) {
 +return true;
 +} else if (arm_feature(env, ARM_FEATURE_EL3) 
 +(env-cp15.scr_el3  SCR_FIQ)) {
 +return true;
 +}
 +}
 +/* In ARMv7 only applies if both Security Extensions (EL3) and
 + * Hypervirtualization Extensions (EL2) implemented, while
 + * for ARMv8 it applies also if only EL3 implemented.
 + */
 +if (arm_feature(env, ARM_FEATURE_EL3) 
 +(arm_feature(env, ARM_FEATURE_EL2) ||
 +arm_feature(env, ARM_FEATURE_V8))) {
 +/* CPSR.F/PSTATE.F ignored if
 + * - exception is taken from Non-secure state
 + * - SCR.FIQ routes exception to monitor mode
 + * - SCR.FW bit is set to 0
 + * - HCR.FMO == 0 (if EL2 implemented)
 + */
 +if ((env-cp15.scr_el3  SCR_FIQ) 
 +!(env-cp15.scr_el3  SCR_FW)) {
 +if (!arm_feature(env, ARM_FEATURE_EL2)) {
 +return true;
 +} else if (!(env-cp15.hcr_el2  HCR_FMO)) {
 +return true;
 +}
 +}
 +}
  }
  return !(env-daif  PSTATE_F);
  case EXCP_IRQ:
 -if (irq_can_hyp  (env-cp15.hcr_el2  HCR_IMO)) {
 -return true;
 +if (!secure) {
 +if (arm_feature(env, ARM_FEATURE_EL2) 
 +(env-cp15.hcr_el2  HCR_IMO)) {
 +/* CPSR.I/PSTATE.I ignored if
 + *  - exception is taken from Non-secure state
 + *  - HCR.IMO == 1
 + *  - either:  - not in Hyp mode
 + * - SCR.IRQ routes exception to monitor mode
 + */
 +if (cur_el  2) {
 +return true;
 +} else if (arm_feature(env, ARM_FEATURE_EL3) 
 +(env-cp15.scr_el3  SCR_IRQ)) {
 +return true;
 +}
 +}
  }
  return 

Re: [Qemu-devel] [PATCH fix for 2.1] makefile: Fix tools compile

2014-07-01 Thread Paolo Bonzini

Il 01/07/2014 10:19, Peter Maydell ha scritto:

 I think something like double x; int f(void) {return isnan(sin(x));}
 should be bullet proof.

This is a compile_prog test, though -- the compiler could spot
that x and f are both unused, since it has the entire program
in hand. My suggestion would be:

int main(int argc, char **argv) { return isnan(sin((double)argc)); }


Ok, v2 of the pull request is on the way.

Paolo



Re: [Qemu-devel] [PULL 3/3] configure: Fix -lm test, so that tools can be compiled on hosts that require -lm

2014-07-01 Thread Peter Maydell
On 1 July 2014 09:22, Paolo Bonzini pbonz...@redhat.com wrote:
 From: Alexey Kardashevskiy a...@ozlabs.ru

 The existing test whether -lm needs to be included or not is
 insufficient as it reports false negative on Fedora20/ppc64.
 This happens because sin(0.0) is a constant value which compiler
 can safely throw away and therefore there is no need to add -lm.
 As the result, qemu-nbd/qemu-io/qemu-img tools cannot compile.

 This adds a global variable and uses it in the test to prevent
 from optimization.

 --- a/configure
 +++ b/configure
 @@ -3453,7 +3453,7 @@ fi
  # Do we need libm
  cat  $TMPC  EOF
  #include math.h
 -int main(void) { return isnan(sin(0.0)); }
 +double x; int main(void) {return isnan(sin(x));}
  EOF
  if compile_prog   ; then
:

This looks to me like we're leaving ourselves open for
a smarter compiler with linktime optimisation to complain
that x is used uninitialized.

thanks
-- PMM



Re: [Qemu-devel] The master branch qemu compiles failed.

2014-07-01 Thread ChenLiang
On 2014/7/1 16:17, Paolo Bonzini wrote:

 Il 01/07/2014 10:00, ChenLiang ha scritto:
 ./configure --enable-debug  --target-list=x86_64-softmmu
 make -j

 net/l2tpv3.c: In function ‘net_l2tpv3_process_queue’:
 net/l2tpv3.c:368: error: invalid use of undefined type ‘struct mmsghdr’
 net/l2tpv3.c:369: error: dereferencing pointer to incomplete type
 net/l2tpv3.c:370: error: dereferencing pointer to incomplete type
 net/l2tpv3.c:371: error: dereferencing pointer to incomplete type
 net/l2tpv3.c: In function ‘net_l2tpv3_send’:
 net/l2tpv3.c:445: error: invalid use of undefined type ‘struct mmsghdr’
 net/l2tpv3.c:448: warning: implicit declaration of function ‘recvmmsg’
 net/l2tpv3.c:448: warning: nested extern declaration of ‘recvmmsg’
 net/l2tpv3.c: In function ‘destroy_vector’:
 net/l2tpv3.c:472: error: dereferencing pointer to incomplete type
 net/l2tpv3.c:473: error: dereferencing pointer to incomplete type
 net/l2tpv3.c:478: error: dereferencing pointer to incomplete type
 net/l2tpv3.c:480: error: increment of pointer to unknown structure
 net/l2tpv3.c:480: error: arithmetic on pointer to an incomplete type
 net/l2tpv3.c: In function ‘build_l2tpv3_vector’:
 net/l2tpv3.c:492: error: invalid application of ‘sizeof’ to incomplete type 
 ‘struct mmsghdr’
 net/l2tpv3.c:495: error: dereferencing pointer to incomplete type
 net/l2tpv3.c:496: error: dereferencing pointer to incomplete type
 net/l2tpv3.c:498: error: dereferencing pointer to incomplete type
 net/l2tpv3.c:504: error: dereferencing pointer to incomplete type
 net/l2tpv3.c:505: error: dereferencing pointer to incomplete type
 net/l2tpv3.c:506: error: dereferencing pointer to incomplete type
 net/l2tpv3.c:507: error: dereferencing pointer to incomplete type
 net/l2tpv3.c:508: error: increment of pointer to unknown structure
 net/l2tpv3.c:508: error: arithmetic on pointer to an incomplete type
 
 What OS and, if Linux, what distro?
 
 Paolo
 
 .
 

linux 3.0.93-0.8-default




Re: [Qemu-devel] [RFC] qemu VGA endian swap low level drawing changes

2014-07-01 Thread Paolo Bonzini

Il 01/07/2014 10:26, Alexander Graf ha scritto:



Right. A quick fix would be to add a flag to force always using a shadow
surface and set it in cirrus ... I'm not sure anybody will notice the
performance difference.

I suspect we can rip out hw cursor emulation and nobody will notice the
difference either ...


Very likely ;). Though I think we're better off keeping it around to
make sure we're still compatible with ancient guests (Windows 3.1 might
use it too). Making it slow however shouldn't make any difference at all.


If you tell me what to look at, I legally own a Windows 98 CD (also NT4 
but I have to dig it out) and can test it later this week.


Paolo



[Qemu-devel] [PULL 01/15] qom: add object_property_add_alias()

2014-07-01 Thread Paolo Bonzini
From: Stefan Hajnoczi stefa...@redhat.com

Sometimes an object needs to present a property which is actually on
another object, or it needs to provide an alias name for an existing
property.

Examples:
  a.foo - b.foo
  a.old_name - a.new_name

The new object_property_add_alias() API allows objects to alias a
property on the same object or another object.  The source and target
names can be different.

Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
Reviewed-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---
 include/qom/object.h | 20 
 qom/object.c | 51 +++
 2 files changed, 71 insertions(+)

diff --git a/include/qom/object.h b/include/qom/object.h
index b882ccc..44c513f 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -1231,6 +1231,26 @@ void object_property_add_uint64_ptr(Object *obj, const 
char *name,
 const uint64_t *v, Error **Errp);
 
 /**
+ * object_property_add_alias:
+ * @obj: the object to add a property to
+ * @name: the name of the property
+ * @target_obj: the object to forward property access to
+ * @target_name: the name of the property on the forwarded object
+ * @errp: if an error occurs, a pointer to an area to store the error
+ *
+ * Add an alias for a property on an object.  This function will add a property
+ * of the same type as the forwarded property.
+ *
+ * The caller must ensure that code@target_obj/code stays alive as long as
+ * this property exists.  In the case of a child object or an alias on the same
+ * object this will be the case.  For aliases to other objects the caller is
+ * responsible for taking a reference.
+ */
+void object_property_add_alias(Object *obj, const char *name,
+   Object *target_obj, const char *target_name,
+   Error **errp);
+
+/**
  * object_child_foreach:
  * @obj: the object whose children will be navigated
  * @fn: the iterator function to be called
diff --git a/qom/object.c b/qom/object.c
index 3876618..a760514 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1550,6 +1550,57 @@ void object_property_add_uint64_ptr(Object *obj, const 
char *name,
 NULL, NULL, (void *)v, errp);
 }
 
+typedef struct {
+Object *target_obj;
+const char *target_name;
+} AliasProperty;
+
+static void property_get_alias(Object *obj, struct Visitor *v, void *opaque,
+   const char *name, Error **errp)
+{
+AliasProperty *prop = opaque;
+
+object_property_get(prop-target_obj, v, prop-target_name, errp);
+}
+
+static void property_set_alias(Object *obj, struct Visitor *v, void *opaque,
+   const char *name, Error **errp)
+{
+AliasProperty *prop = opaque;
+
+object_property_set(prop-target_obj, v, prop-target_name, errp);
+}
+
+static void property_release_alias(Object *obj, const char *name, void *opaque)
+{
+AliasProperty *prop = opaque;
+
+g_free(prop);
+}
+
+void object_property_add_alias(Object *obj, const char *name,
+   Object *target_obj, const char *target_name,
+   Error **errp)
+{
+AliasProperty *prop;
+ObjectProperty *target_prop;
+
+target_prop = object_property_find(target_obj, target_name, errp);
+if (!target_prop) {
+return;
+}
+
+prop = g_malloc(sizeof(*prop));
+prop-target_obj = target_obj;
+prop-target_name = target_name;
+
+object_property_add(obj, name, target_prop-type,
+property_get_alias,
+property_set_alias,
+property_release_alias,
+prop, errp);
+}
+
 static void object_instance_init(Object *obj)
 {
 object_property_add_str(obj, type, qdev_get_type, NULL, NULL);
-- 
1.8.3.1





[Qemu-devel] [PULL for 2.1 00/15] MemoryRegion QOMification

2014-07-01 Thread Paolo Bonzini
The following changes since commit 53a259da5697ec8a82463161e2e32ff942a08bc2:

  Merge remote-tracking branch 
'remotes/awilliam/tags/vfio-pci-for-qemu-20140630.0' into staging (2014-06-30 
18:31:07 +0100)

are available in the git repository at:


  git://github.com/bonzini/qemu.git memory

for you to fetch changes up to 352e8da743f26948cb12d0ee53c455f328f59bbe:

  qdev: correctly send DEVICE_DELETED for recursively-deleted devices 
(2014-07-01 10:20:42 +0200)

Patch 1 is shared with Stefan's upcoming pull request.  We synchronized
in order to use the same commit ID and thus avoid conflicts.


Marcelo Tosatti (1):
  mc146818rtc: add rtc-time link to /machine/rtc

Paolo Bonzini (7):
  qom: add a generic mechanism to resolve paths
  qom: allow creating an alias of a child property
  libqtest: escape strings in QMP commands, fix leak
  memory: MemoryRegion: use /machine as default owner
  memory: MemoryRegion: replace owner field with QOM parent
  memory: do not give a name to the internal exec.c regions
  qdev: correctly send DEVICE_DELETED for recursively-deleted devices

Peter Crosthwaite (6):
  qom: object: remove parent pointer when unparenting
  qom: object: Ignore refs/unrefs of NULL
  memory: MemoryRegion: QOMify
  memory: MemoryRegion: Add container and addr props
  memory: MemoryRegion: Add may-overlap and priority props
  memory: MemoryRegion: Add size property

Stefan Hajnoczi (1):
  qom: add object_property_add_alias()

 exec.c |  12 +--
 hw/core/qdev.c |   5 +-
 hw/timer/mc146818rtc.c |   9 ++
 include/exec/memory.h  |   9 +-
 include/hw/qdev-core.h |   1 +
 include/qom/object.h   |  54 ++--
 memory.c   | 231 +++--
 qom/object.c   | 148 ---
 tests/fdc-test.c   |   2 +-
 tests/libqtest.c   |  47 +++---
 tests/qom-test.c   |   6 +-
 tests/tmp105-test.c|   4 +-
 vl.c   |   3 +-
 13 files changed, 442 insertions(+), 89 deletions(-)
-- 
1.8.3.1




[Qemu-devel] [PULL 04/15] mc146818rtc: add rtc-time link to /machine/rtc

2014-07-01 Thread Paolo Bonzini
From: Marcelo Tosatti mtosa...@redhat.com

Add a link to rtc under /machine providing a stable
location for management apps to query the value of the
time.  The link should be added by any object that sends
RTC_TIME_CHANGE events.

{execute:qom-get,arguments:{path:/machine,property:rtc-time} }

Suggested by Paolo Bonzini and Andreas Faerber.

Signed-off-by: Marcelo Tosatti mtosa...@redhat.com
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 hw/timer/mc146818rtc.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c
index 307732c..9d817ca 100644
--- a/hw/timer/mc146818rtc.c
+++ b/hw/timer/mc146818rtc.c
@@ -909,6 +909,9 @@ static void rtc_realizefn(DeviceState *dev, Error **errp)
 
 object_property_add(OBJECT(s), date, struct tm,
 rtc_get_date, NULL, NULL, s, NULL);
+
+object_property_add_alias(qdev_get_machine(), rtc-time,
+  OBJECT(s), date, NULL);
 }
 
 ISADevice *rtc_init(ISABus *bus, int base_year, qemu_irq intercept_irq)
@@ -950,11 +953,17 @@ static void rtc_class_initfn(ObjectClass *klass, void 
*data)
 dc-cannot_instantiate_with_device_add_yet = true;
 }
 
+static void rtc_finalize(Object *obj)
+{
+object_property_del(qdev_get_machine(), rtc, NULL);
+}
+
 static const TypeInfo mc146818rtc_info = {
 .name  = TYPE_MC146818_RTC,
 .parent= TYPE_ISA_DEVICE,
 .instance_size = sizeof(RTCState),
 .class_init= rtc_class_initfn,
+.instance_finalize = rtc_finalize,
 };
 
 static void mc146818rtc_register_types(void)
-- 
1.8.3.1





[Qemu-devel] [PULL 08/15] memory: MemoryRegion: use /machine as default owner

2014-07-01 Thread Paolo Bonzini
This will be added (after QOMification) as the QOM parent.

Reviewed-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 memory.c | 2 +-
 vl.c | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/memory.c b/memory.c
index b91a60a..7eaa1e9 100644
--- a/memory.c
+++ b/memory.c
@@ -849,7 +849,7 @@ void memory_region_init(MemoryRegion *mr,
 {
 mr-ops = unassigned_mem_ops;
 mr-opaque = NULL;
-mr-owner = owner;
+mr-owner = owner ? owner : qdev_get_machine();
 mr-iommu_ops = NULL;
 mr-container = NULL;
 mr-size = int128_make64(size);
diff --git a/vl.c b/vl.c
index 41ddcd2..88feeab 100644
--- a/vl.c
+++ b/vl.c
@@ -3986,12 +3986,11 @@ int main(int argc, char **argv, char **envp)
 exit(1);
 }
 
-cpu_exec_init_all();
-
 current_machine = MACHINE(object_new(object_class_get_name(
   OBJECT_CLASS(machine_class;
 object_property_add_child(object_get_root(), machine,
   OBJECT(current_machine), error_abort);
+cpu_exec_init_all();
 
 if (machine_class-hw_version) {
 qemu_set_version(machine_class-hw_version);
-- 
1.8.3.1





[Qemu-devel] [PULL 03/15] qom: allow creating an alias of a child property

2014-07-01 Thread Paolo Bonzini
Child properties must be unique.  Fix this problem by
turning their aliases into links.

The resolve function that forwards to the target property
does not have any knowledge of the target property's type,
so it works fine.

Reviewed-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 qom/object.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/qom/object.c b/qom/object.c
index 7a892ef..f49335f 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1607,22 +1607,32 @@ void object_property_add_alias(Object *obj, const char 
*name,
 AliasProperty *prop;
 ObjectProperty *op;
 ObjectProperty *target_prop;
+gchar *prop_type;
 
 target_prop = object_property_find(target_obj, target_name, errp);
 if (!target_prop) {
 return;
 }
 
+if (object_property_is_child(target_prop)) {
+prop_type = g_strdup_printf(link%s,
+target_prop-type + strlen(child));
+} else {
+prop_type = g_strdup(target_prop-type);
+}
+
 prop = g_malloc(sizeof(*prop));
 prop-target_obj = target_obj;
 prop-target_name = target_name;
 
-op = object_property_add(obj, name, target_prop-type,
+op = object_property_add(obj, name, prop_type,
  property_get_alias,
  property_set_alias,
  property_release_alias,
  prop, errp);
 op-resolve = property_resolve_alias;
+
+g_free(prop_type);
 }
 
 static void object_instance_init(Object *obj)
-- 
1.8.3.1





[Qemu-devel] [PULL 05/15] qom: object: remove parent pointer when unparenting

2014-07-01 Thread Paolo Bonzini
From: Peter Crosthwaite peter.crosthwa...@xilinx.com

Certain parts of the QOM framework test this pointer to determine if
an object is parented. Nuke it when the object is unparented to allow
for reuse of an object after unparenting.

Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 qom/object.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/qom/object.c b/qom/object.c
index f49335f..d5de8f6 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -397,6 +397,7 @@ void object_unparent(Object *obj)
 }
 if (obj-parent) {
 object_property_del_child(obj-parent, obj, NULL);
+obj-parent = NULL;
 }
 object_unref(obj);
 }
-- 
1.8.3.1





[Qemu-devel] [PULL 10/15] memory: MemoryRegion: replace owner field with QOM parent

2014-07-01 Thread Paolo Bonzini
The two are now the same.

Reviewed-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 include/exec/memory.h |  1 -
 memory.c  | 35 +--
 2 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/include/exec/memory.h b/include/exec/memory.h
index 85b56e2..0c7e825 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -141,7 +141,6 @@ struct MemoryRegion {
 const MemoryRegionOps *ops;
 const MemoryRegionIOMMUOps *iommu_ops;
 void *opaque;
-struct Object *owner;
 MemoryRegion *container;
 Int128 size;
 hwaddr addr;
diff --git a/memory.c b/memory.c
index 9397fec..8970081 100644
--- a/memory.c
+++ b/memory.c
@@ -905,9 +905,11 @@ void memory_region_init(MemoryRegion *mr,
 const char *name,
 uint64_t size)
 {
-object_initialize(mr, sizeof(*mr), TYPE_MEMORY_REGION);
+if (!owner) {
+owner = qdev_get_machine();
+}
 
-mr-owner = owner ? owner : qdev_get_machine();
+object_initialize(mr, sizeof(*mr), TYPE_MEMORY_REGION);
 mr-size = int128_make64(size);
 if (size == UINT64_MAX) {
 mr-size = int128_2_64();
@@ -915,7 +917,7 @@ void memory_region_init(MemoryRegion *mr,
 mr-name = g_strdup(name);
 
 if (name) {
-object_property_add_child_array(mr-owner, name, OBJECT(mr));
+object_property_add_child_array(owner, name, OBJECT(mr));
 object_unref(OBJECT(mr));
 }
 }
@@ -1187,24 +1189,37 @@ void memory_region_destroy(MemoryRegion *mr)
 
 Object *memory_region_owner(MemoryRegion *mr)
 {
-return mr-owner;
+Object *obj = OBJECT(mr);
+return obj-parent;
 }
 
 void memory_region_ref(MemoryRegion *mr)
 {
-if (mr  mr-owner) {
-object_ref(mr-owner);
+/* MMIO callbacks most likely will access data that belongs
+ * to the owner, hence the need to ref/unref the owner whenever
+ * the memory region is in use.
+ *
+ * The memory region is a child of its owner.  As long as the
+ * owner doesn't call unparent itself on the memory region,
+ * ref-ing the owner will also keep the memory region alive.
+ * Memory regions without an owner are supposed to never go away,
+ * but we still ref/unref them for debugging purposes.
+ */
+Object *obj = OBJECT(mr);
+if (obj  obj-parent) {
+object_ref(obj-parent);
 } else {
-object_ref(OBJECT(mr));
+object_ref(obj);
 }
 }
 
 void memory_region_unref(MemoryRegion *mr)
 {
-if (mr  mr-owner) {
-object_unref(mr-owner);
+Object *obj = OBJECT(mr);
+if (obj  obj-parent) {
+object_unref(obj-parent);
 } else {
-object_unref(OBJECT(mr));
+object_unref(obj);
 }
 }
 
-- 
1.8.3.1





[Qemu-devel] [PULL 02/15] qom: add a generic mechanism to resolve paths

2014-07-01 Thread Paolo Bonzini
It may be desirable to have custom link properties that do more
than just store an object.  Even the addition of a check
function is not enough if setting the link has side effects
or if a non-standard reference counting is preferrable.

Avoid the assumption that the opaque field of a link is a
LinkProperty struct, by adding a generic resolve callback
to ObjectProperty.  This fixes aliases of link properties.

Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 include/qom/object.h | 34 ++
 qom/object.c | 82 +---
 2 files changed, 82 insertions(+), 34 deletions(-)

diff --git a/include/qom/object.h b/include/qom/object.h
index 44c513f..8a05a81 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -304,6 +304,25 @@ typedef void (ObjectPropertyAccessor)(Object *obj,
   Error **errp);
 
 /**
+ * ObjectPropertyResolve:
+ * @obj: the object that owns the property
+ * @opaque: the opaque registered with the property
+ * @part: the name of the property
+ *
+ * Resolves the #Object corresponding to property @part.
+ *
+ * The returned object can also be used as a starting point
+ * to resolve a relative path starting with @part.
+ *
+ * Returns: If @path is the path that led to @obj, the function
+ * returns the #Object corresponding to @path/@part.
+ * If @path/@part is not a valid object path, it returns #NULL.
+ */
+typedef Object *(ObjectPropertyResolve)(Object *obj,
+void *opaque,
+const char *part);
+
+/**
  * ObjectPropertyRelease:
  * @obj: the object that owns the property
  * @name: the name of the property
@@ -321,6 +340,7 @@ typedef struct ObjectProperty
 gchar *type;
 ObjectPropertyAccessor *get;
 ObjectPropertyAccessor *set;
+ObjectPropertyResolve *resolve;
 ObjectPropertyRelease *release;
 void *opaque;
 
@@ -787,12 +807,16 @@ void object_unref(Object *obj);
  *   destruction.  This may be NULL.
  * @opaque: an opaque pointer to pass to the callbacks for the property
  * @errp: returns an error if this function fails
+ *
+ * Returns: The #ObjectProperty; this can be used to set the @resolve
+ * callback for child and link properties.
  */
-void object_property_add(Object *obj, const char *name, const char *type,
- ObjectPropertyAccessor *get,
- ObjectPropertyAccessor *set,
- ObjectPropertyRelease *release,
- void *opaque, Error **errp);
+ObjectProperty *object_property_add(Object *obj, const char *name,
+const char *type,
+ObjectPropertyAccessor *get,
+ObjectPropertyAccessor *set,
+ObjectPropertyRelease *release,
+void *opaque, Error **errp);
 
 void object_property_del(Object *obj, const char *name, Error **errp);
 
diff --git a/qom/object.c b/qom/object.c
index a760514..7a892ef 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -356,11 +356,6 @@ static inline bool object_property_is_child(ObjectProperty 
*prop)
 return strstart(prop-type, child, NULL);
 }
 
-static inline bool object_property_is_link(ObjectProperty *prop)
-{
-return strstart(prop-type, link, NULL);
-}
-
 static void object_property_del_all(Object *obj)
 {
 while (!QTAILQ_EMPTY(obj-properties)) {
@@ -728,11 +723,12 @@ void object_unref(Object *obj)
 }
 }
 
-void object_property_add(Object *obj, const char *name, const char *type,
- ObjectPropertyAccessor *get,
- ObjectPropertyAccessor *set,
- ObjectPropertyRelease *release,
- void *opaque, Error **errp)
+ObjectProperty *
+object_property_add(Object *obj, const char *name, const char *type,
+ObjectPropertyAccessor *get,
+ObjectPropertyAccessor *set,
+ObjectPropertyRelease *release,
+void *opaque, Error **errp)
 {
 ObjectProperty *prop;
 
@@ -741,7 +737,7 @@ void object_property_add(Object *obj, const char *name, 
const char *type,
 error_setg(errp, attempt to add duplicate property '%s'
 to object (type '%s'), name,
object_get_typename(obj));
-return;
+return NULL;
 }
 }
 
@@ -756,6 +752,7 @@ void object_property_add(Object *obj, const char *name, 
const char *type,
 prop-opaque = opaque;
 
 QTAILQ_INSERT_TAIL(obj-properties, prop, node);
+return prop;
 }
 
 ObjectProperty *object_property_find(Object *obj, const char *name,
@@ -1028,6 +1025,11 @@ static void object_get_child_property(Object *obj, 
Visitor *v, void *opaque,
 g_free(path);
 }
 
+static Object 

[Qemu-devel] [PULL 07/15] libqtest: escape strings in QMP commands, fix leak

2014-07-01 Thread Paolo Bonzini
libqtest is using g_strdup_printf to format QMP commands, but
this does not work if the argument strings need to be escaped.
Instead, use the fancy %-formatting functionality of QObject.
The only change required in tests is that strings have to be
formatted as %s, not '%s' or \%s\.  Luckily this usage of
parameterized QMP commands is not that frequent.

The leak is in socket_sendf.  Since we are extracting the send
loop to a new function, fix it now.

Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 tests/fdc-test.c|  2 +-
 tests/libqtest.c| 47 +--
 tests/qom-test.c|  6 +++---
 tests/tmp105-test.c |  4 ++--
 4 files changed, 43 insertions(+), 16 deletions(-)

diff --git a/tests/fdc-test.c b/tests/fdc-test.c
index 37096dc..c8e1e7b 100644
--- a/tests/fdc-test.c
+++ b/tests/fdc-test.c
@@ -291,7 +291,7 @@ static void test_media_insert(void)
 /* Insert media in drive. DSKCHK should not be reset until a step pulse
  * is sent. */
 qmp_discard_response({'execute':'change', 'arguments':{
-  'device':'floppy0', 'target': '%s' }},
+  'device':'floppy0', 'target': %s }},
  test_image);
 qmp_discard_response(); /* ignore event
  (FIXME open - open transition?!) */
diff --git a/tests/libqtest.c b/tests/libqtest.c
index 71468ac..98e8f4b 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -30,8 +30,9 @@
 
 #include qemu/compiler.h
 #include qemu/osdep.h
-#include qapi/qmp/json-streamer.h
 #include qapi/qmp/json-parser.h
+#include qapi/qmp/json-streamer.h
+#include qapi/qmp/qjson.h
 
 #define MAX_IRQ 256
 #define SOCKET_TIMEOUT 5
@@ -220,19 +221,15 @@ void qtest_quit(QTestState *s)
 g_free(s);
 }
 
-static void socket_sendf(int fd, const char *fmt, va_list ap)
+static void socket_send(int fd, const char *buf, size_t size)
 {
-gchar *str;
-size_t size, offset;
-
-str = g_strdup_vprintf(fmt, ap);
-size = strlen(str);
+size_t offset;
 
 offset = 0;
 while (offset  size) {
 ssize_t len;
 
-len = write(fd, str + offset, size - offset);
+len = write(fd, buf + offset, size - offset);
 if (len == -1  errno == EINTR) {
 continue;
 }
@@ -244,6 +241,15 @@ static void socket_sendf(int fd, const char *fmt, va_list 
ap)
 }
 }
 
+static void socket_sendf(int fd, const char *fmt, va_list ap)
+{
+gchar *str = g_strdup_vprintf(fmt, ap);
+size_t size = strlen(str);
+
+socket_send(fd, str, size);
+g_free(str);
+}
+
 static void GCC_FMT_ATTR(2, 3) qtest_sendf(QTestState *s, const char *fmt, ...)
 {
 va_list ap;
@@ -378,8 +384,29 @@ QDict *qtest_qmp_receive(QTestState *s)
 
 QDict *qtest_qmpv(QTestState *s, const char *fmt, va_list ap)
 {
-/* Send QMP request */
-socket_sendf(s-qmp_fd, fmt, ap);
+va_list ap_copy;
+QObject *qobj;
+
+/* Going through qobject ensures we escape strings properly.
+ * This seemingly unnecessary copy is required in case va_list
+ * is an array type.
+ */
+va_copy(ap_copy, ap);
+qobj = qobject_from_jsonv(fmt, ap_copy);
+va_end(ap_copy);
+
+/* No need to send anything for an empty QObject.  */
+if (qobj) {
+QString *qstr = qobject_to_json(qobj);
+const char *str = qstring_get_str(qstr);
+size_t size = qstring_get_length(qstr);
+
+/* Send QMP request */
+socket_send(s-qmp_fd, str, size);
+
+QDECREF(qstr);
+qobject_decref(qobj);
+}
 
 /* Receive reply */
 return qtest_qmp_receive(s);
diff --git a/tests/qom-test.c b/tests/qom-test.c
index d8d1d8d..4246382 100644
--- a/tests/qom-test.c
+++ b/tests/qom-test.c
@@ -53,7 +53,7 @@ static void test_properties(const char *path, bool recurse)
 
 g_test_message(Obtaining properties of %s, path);
 response = qmp({ 'execute': 'qom-list',
- 'arguments': { 'path': '%s' } }, path);
+ 'arguments': { 'path': %s } }, path);
 g_assert(response);
 
 if (!recurse) {
@@ -76,8 +76,8 @@ static void test_properties(const char *path, bool recurse)
 const char *prop = qdict_get_str(tuple, name);
 g_test_message(Testing property %s.%s, path, prop);
 response = qmp({ 'execute': 'qom-get',
- 'arguments': { 'path': '%s',
-'property': '%s' } },
+ 'arguments': { 'path': %s,
+'property': %s } },
path, prop);
 /* qom-get may fail but should not, e.g., segfault. */
 g_assert(response);
diff --git a/tests/tmp105-test.c b/tests/tmp105-test.c
index 15ddaf3..99db538 100644
--- a/tests/tmp105-test.c
+++ b/tests/tmp105-test.c
@@ -69,7 +69,7 @@ static int qmp_tmp105_get_temperature(const char *id)
 QDict *response;
 

[Qemu-devel] [PULL 14/15] memory: do not give a name to the internal exec.c regions

2014-07-01 Thread Paolo Bonzini
There is no need to have them visible under /machine.

Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 exec.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/exec.c b/exec.c
index df4a080..5a2a25e 100644
--- a/exec.c
+++ b/exec.c
@@ -1801,13 +1801,13 @@ MemoryRegion *iotlb_to_region(AddressSpace *as, hwaddr 
index)
 
 static void io_mem_init(void)
 {
-memory_region_init_io(io_mem_rom, NULL, unassigned_mem_ops, NULL, rom, 
UINT64_MAX);
+memory_region_init_io(io_mem_rom, NULL, unassigned_mem_ops, NULL, NULL, 
UINT64_MAX);
 memory_region_init_io(io_mem_unassigned, NULL, unassigned_mem_ops, NULL,
-  unassigned, UINT64_MAX);
+  NULL, UINT64_MAX);
 memory_region_init_io(io_mem_notdirty, NULL, notdirty_mem_ops, NULL,
-  notdirty, UINT64_MAX);
+  NULL, UINT64_MAX);
 memory_region_init_io(io_mem_watch, NULL, watch_mem_ops, NULL,
-  watch, UINT64_MAX);
+  NULL, UINT64_MAX);
 }
 
 static void mem_begin(MemoryListener *listener)
-- 
1.8.3.1





[Qemu-devel] [PULL 13/15] memory: MemoryRegion: Add size property

2014-07-01 Thread Paolo Bonzini
From: Peter Crosthwaite peter.crosthwa...@xilinx.com

To allow devices to dynamically resize the device. The motivation is
to allow devices with variable size to init their memory_region
without size early and then correctly populate size at realize() time.

Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 memory.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/memory.c b/memory.c
index 834959b..64d7176 100644
--- a/memory.c
+++ b/memory.c
@@ -971,6 +971,15 @@ static bool memory_region_get_may_overlap(Object *obj, 
Error **errp)
 return mr-may_overlap;
 }
 
+static void memory_region_get_size(Object *obj, Visitor *v, void *opaque,
+   const char *name, Error **errp)
+{
+MemoryRegion *mr = MEMORY_REGION(obj);
+uint64_t value = memory_region_size(mr);
+
+visit_type_uint64(v, value, name, errp);
+}
+
 static void memory_region_initfn(Object *obj)
 {
 MemoryRegion *mr = MEMORY_REGION(obj);
@@ -1002,6 +1011,10 @@ static void memory_region_initfn(Object *obj)
  memory_region_get_may_overlap,
  NULL, /* memory_region_set_may_overlap */
  error_abort);
+object_property_add(OBJECT(mr), size, uint64,
+memory_region_get_size,
+NULL, /* memory_region_set_size, */
+NULL, NULL, error_abort);
 }
 
 static uint64_t unassigned_mem_read(void *opaque, hwaddr addr,
-- 
1.8.3.1





[Qemu-devel] [PULL 15/15] qdev: correctly send DEVICE_DELETED for recursively-deleted devices

2014-07-01 Thread Paolo Bonzini
When a device is unparented (i.e. made completely hidden from management)
we want to send a DEVICE_DELETED event only if the device actually was
realized.  This avoids raising DEVICE_DELETED events when device_add
fails.

However, this does not work right for recursively-deleted
devices: the whole tree is _first_ unrealized, _then_ unparented.
Then device_unparent sees realized==false and fails to trigger
the event.  The solution is simply to move have_realized into
the DeviceState struct.  If device_add fails, we never set the
new field to true and DEVICE_DELETED is not sent.

Fixes qemu-iotests testcase 067 (broken by commit 5942a19, though that
commit in turn fixed a possible segfault in the same test).

Reported-by: Markus Armbruster arm...@redhat.com
Reviewed-by: Markus Armbruster arm...@redhat.com
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 hw/core/qdev.c | 5 +++--
 include/hw/qdev-core.h | 1 +
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index d1eba3c..c520415 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -848,6 +848,7 @@ static void device_set_realized(Object *obj, bool value, 
Error **errp)
 if (dev-hotplugged  local_err == NULL) {
 device_reset(dev);
 }
+dev-pending_deleted_event = false;
 } else if (!value  dev-realized) {
 QLIST_FOREACH(bus, dev-child_bus, sibling) {
 object_property_set_bool(OBJECT(bus), false, realized,
@@ -862,6 +863,7 @@ static void device_set_realized(Object *obj, bool value, 
Error **errp)
 if (dc-unrealize  local_err == NULL) {
 dc-unrealize(dev, local_err);
 }
+dev-pending_deleted_event = true;
 }
 
 if (local_err != NULL) {
@@ -972,7 +974,6 @@ static void device_unparent(Object *obj)
 {
 DeviceState *dev = DEVICE(obj);
 BusState *bus;
-bool have_realized = dev-realized;
 
 if (dev-realized) {
 object_property_set_bool(obj, false, realized, NULL);
@@ -988,7 +989,7 @@ static void device_unparent(Object *obj)
 }
 
 /* Only send event if the device had been completely realized */
-if (have_realized) {
+if (dev-pending_deleted_event) {
 gchar *path = object_get_canonical_path(OBJECT(dev));
 
 qapi_event_send_device_deleted(!!dev-id, dev-id, path, error_abort);
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 9221cfc..0799ff2 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -156,6 +156,7 @@ struct DeviceState {
 
 const char *id;
 bool realized;
+bool pending_deleted_event;
 QemuOpts *opts;
 int hotplugged;
 BusState *parent_bus;
-- 
1.8.3.1




[Qemu-devel] [Bug 1336194] [NEW] Errors reporting in do_delvm caused a crash

2014-07-01 Thread Étienne Buira
Public bug reported:

In case of multiple errors, it leads to a crash.

Typical back trace:
#0  in libc in __GI_raise (sig=sig@entry=6) at 
../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  in libc in __GI_abort () at abort.c:90
#2  in libc in __libc_message (do_abort=do_abort@entry=2, fmt=fmt@entry=in 
libc *** Error in `%s': %s: 0x%s ***\n) at 
../sysdeps/unix/sysv/linux/libc_fatal.c:196
#3  in libc in malloc_printerr (action=3, str=in libc double free or 
corruption (out), ptr=optimized out) at malloc.c:4902
#4  in libc in _int_free (av=optimized out, p=in heap chunk, have_lock=0) 
at malloc.c:3758
#5  in qemu binary in error_free (err=in heap chunk) at util/error.c:166
#6  in qemu binary in do_delvm (mon=in heap chunk, qdict=optimized out) 
at /home/qemudbg/src/qemu/savevm.c:1132
#7  in qemu binary in handle_user_command (mon=mon@entry=in heap chunk, 
cmdline=optimized out) at /home/qemudbg/src/qemu/monitor.c:4167
#8  in qemu binary in monitor_command_cb (opaque=in heap chunk, 
cmdline=optimized out, readline_opaque=optimized out) at 
/home/qemudbg/src/qemu/monitor.c:4878
#9  in qemu binary in readline_handle_byte (rs=in heap, ch=optimized out) 
at util/readline.c:371
#10 in qemu binary in monitor_read (opaque=optimized out, buf=optimized 
out, size=optimized out) at /home/qemudbg/src/qemu/monitor.c:4861
#11 in qemu binary in qemu_chr_be_write (len=optimized out, buf=in stack 
\n\003, s=in heap chunk) at qemu-char.c:165
#12 tcp_chr_read (chan=optimized out, cond=optimized out, opaque=in heap 
chunk) at qemu-char.c:2487
#13 in libglib in g_main_context_dispatch () from /usr/lib64/libglib-2.0.so.0
#14 in qemu binary in glib_pollfds_poll () at main-loop.c:190
#15 os_host_main_loop_wait (timeout=optimized out) at main-loop.c:235
#16 main_loop_wait (nonblocking=optimized out) at main-loop.c:484
#17 in qemu binary in main_loop () at vl.c:2051
#18 main (argc=optimized out, argv=optimized out, envp=optimized out) at 
vl.c:4507

** Affects: qemu
 Importance: Undecided
 Status: New

** Patch added: 0002-do_delvm-nullify-err-after-free.patch
   
https://bugs.launchpad.net/bugs/1336194/+attachment/4142937/+files/0002-do_delvm-nullify-err-after-free.patch

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1336194

Title:
  Errors reporting in do_delvm caused a crash

Status in QEMU:
  New

Bug description:
  In case of multiple errors, it leads to a crash.

  Typical back trace:
  #0  in libc in __GI_raise (sig=sig@entry=6) at 
../nptl/sysdeps/unix/sysv/linux/raise.c:56
  #1  in libc in __GI_abort () at abort.c:90
  #2  in libc in __libc_message (do_abort=do_abort@entry=2, fmt=fmt@entry=in 
libc *** Error in `%s': %s: 0x%s ***\n) at 
../sysdeps/unix/sysv/linux/libc_fatal.c:196
  #3  in libc in malloc_printerr (action=3, str=in libc double free or 
corruption (out), ptr=optimized out) at malloc.c:4902
  #4  in libc in _int_free (av=optimized out, p=in heap chunk, 
have_lock=0) at malloc.c:3758
  #5  in qemu binary in error_free (err=in heap chunk) at util/error.c:166
  #6  in qemu binary in do_delvm (mon=in heap chunk, qdict=optimized out) 
at /home/qemudbg/src/qemu/savevm.c:1132
  #7  in qemu binary in handle_user_command (mon=mon@entry=in heap chunk, 
cmdline=optimized out) at /home/qemudbg/src/qemu/monitor.c:4167
  #8  in qemu binary in monitor_command_cb (opaque=in heap chunk, 
cmdline=optimized out, readline_opaque=optimized out) at 
/home/qemudbg/src/qemu/monitor.c:4878
  #9  in qemu binary in readline_handle_byte (rs=in heap, ch=optimized 
out) at util/readline.c:371
  #10 in qemu binary in monitor_read (opaque=optimized out, buf=optimized 
out, size=optimized out) at /home/qemudbg/src/qemu/monitor.c:4861
  #11 in qemu binary in qemu_chr_be_write (len=optimized out, buf=in 
stack \n\003, s=in heap chunk) at qemu-char.c:165
  #12 tcp_chr_read (chan=optimized out, cond=optimized out, opaque=in heap 
chunk) at qemu-char.c:2487
  #13 in libglib in g_main_context_dispatch () from 
/usr/lib64/libglib-2.0.so.0
  #14 in qemu binary in glib_pollfds_poll () at main-loop.c:190
  #15 os_host_main_loop_wait (timeout=optimized out) at main-loop.c:235
  #16 main_loop_wait (nonblocking=optimized out) at main-loop.c:484
  #17 in qemu binary in main_loop () at vl.c:2051
  #18 main (argc=optimized out, argv=optimized out, envp=optimized out) 
at vl.c:4507

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1336194/+subscriptions



Re: [Qemu-devel] [PATCH v2] qemu-iotests: Disable Quorum testing in 041 when Quorum is not builtin

2014-07-01 Thread Stefan Hajnoczi
On Tue, Jul 1, 2014 at 10:10 AM, Kevin Wolf kw...@redhat.com wrote:
 Am 30.06.2014 um 16:09 hat Stefan Hajnoczi geschrieben:
 On Fri, Jun 27, 2014 at 10:17:16PM +0200, Benoît Canet wrote:
 I think this patch can be boiled down to 2 lines:

  if __name__ == '__main__':
 +if 'quorum' not in iotests.qemu_img('--help'):
 +iotests.notrun('not built with quorum support')
  iotests.main(supported_fmts=['qcow2', 'qed'])

 What do you think?

 That would disable the whole test case 041, whereas Benoît's patch
 only disables the quorum-related part. (The test case is really about
 migration, not only quorum.)

Good point.  I thought about skipping TestRepairQuorum to avoid all
those if statements (which are also easy to forget when adding a new
test case) but it would be more hassle than just having the if
statements.

I now think the original approach was right, just simplify
has_quorum() using qemu_img_pipe() instead of using subprocess.

Stefan



[Qemu-devel] [PULL for-2.1 00/24] Block patches

2014-07-01 Thread Stefan Hajnoczi
The following changes since commit 53a259da5697ec8a82463161e2e32ff942a08bc2:

  Merge remote-tracking branch 
'remotes/awilliam/tags/vfio-pci-for-qemu-20140630.0' into staging (2014-06-30 
18:31:07 +0100)

are available in the git repository at:


  git://github.com/stefanha/qemu.git tags/block-pull-request

for you to fetch changes up to 13d8cc515dfcf5574077f964332d34890c0101d0:

  block: add backing-file option to block-stream (2014-07-01 10:47:01 +0200)


Block pull request


Benoît Canet (1):
  qapi: Change back sector-count to sectors-count in quorum QAPI events.

Chunyan Liu (1):
  qemu-img create: add 'nocow' option

Cornelia Huck (1):
  dataplane: bail out on unsupported transport

Jeff Cody (6):
  block: make 'top' argument to block-commit optional
  block: simplify bdrv_find_base() and bdrv_find_overlay()
  block: add QAPI command to allow live backing file change
  block: add helper function to determine if a BDS is in a chain
  block: extend block-commit to accept a string for the backing file
  block: add backing-file option to block-stream

Max Reitz (3):
  iotests: Simplify qemu-iotests-quick.sh
  iotests: Add qemu tests to quick group
  iotests: Add more tests to quick group

Peter Maydell (1):
  block/cow: Avoid use of uninitialized cow_bs in error path

Stefan Hajnoczi (11):
  qom: add object_property_add_alias()
  virtio-blk: avoid qdev property definition duplication
  virtio-blk: move x-data-plane qdev property to virtio-blk.h
  qdev: add qdev_alias_all_properties()
  virtio-blk: use aliases instead of duplicate qdev properties
  virtio-blk: drop virtio_blk_set_conf()
  virtio: fix virtio-blk child refcount in transports
  virtio-blk: move qdev properties into virtio-blk.c
  virtio-blk: replace x-iothread with iothread link property
  qdev: drop iothread property type
  virtio-blk: remove need for explicit x-data-plane=on option

 block.c  |  64 +---
 block/commit.c   |   9 ++-
 block/cow.c  |   7 ++-
 block/qed.c  |   6 +-
 block/raw-posix.c|  25 
 block/stream.c   |  11 ++--
 block/vdi.c  |  29 +
 block/vmdk.c |   6 +-
 block/vpc.c  |  29 +
 blockdev.c   | 126 ---
 docs/qmp/qmp-events.txt  |  26 
 hmp.c|   2 +-
 hw/block/dataplane/virtio-blk.c  |  12 +++-
 hw/block/virtio-blk.c|  28 ++---
 hw/core/qdev-properties-system.c |  50 
 hw/core/qdev.c   |  21 +++
 hw/s390x/s390-virtio-bus.c   |  12 ++--
 hw/s390x/s390-virtio-bus.h   |   1 -
 hw/s390x/virtio-ccw.c|   9 ++-
 hw/s390x/virtio-ccw.h|   1 -
 hw/virtio/virtio-pci.c   |   9 ++-
 hw/virtio/virtio-pci.h   |   1 -
 include/block/block.h|   4 +-
 include/block/block_int.h|   4 +-
 include/hw/qdev-properties.h |   5 +-
 include/hw/virtio/virtio-blk.h   |  19 --
 include/qom/object.h |  20 +++
 qapi/block-core.json |  72 +++---
 qapi/event.json  |   8 +--
 qemu-doc.texi|  16 +
 qemu-img.texi|  16 +
 qmp-commands.hx  |  63 +++-
 qom/object.c |  51 
 tests/qemu-iotests-quick.sh  |  12 +---
 tests/qemu-iotests/040   |  28 +
 tests/qemu-iotests/082.out   |  24 
 tests/qemu-iotests/group |  56 -
 37 files changed, 640 insertions(+), 242 deletions(-)

-- 
1.9.3




[Qemu-devel] [PULL for-2.1 02/24] virtio-blk: avoid qdev property definition duplication

2014-07-01 Thread Stefan Hajnoczi
It becomes unwiedly to duplicate all virtio-blk qdev property
definitions due to an #ifdef.  The C preprocessor syntax makes it a
little hard to resolve this cleanly but we can extract the #ifdef and
call a macro it defines later.

Avoiding duplication is important since it will only get worse when we
move the x-data-plane qdev property here too.  We'd have a combinatorial
explosion since x-data-plane has its own #ifdef.

Suggested-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
Reviewed-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---
 include/hw/virtio/virtio-blk.h | 14 ++
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h
index d0fb26f..ee43f7a 100644
--- a/include/hw/virtio/virtio-blk.h
+++ b/include/hw/virtio/virtio-blk.h
@@ -156,21 +156,19 @@ typedef struct VirtIOBlockReq {
 DEFINE_VIRTIO_COMMON_FEATURES(_state, _field)
 
 #ifdef __linux__
-#define DEFINE_VIRTIO_BLK_PROPERTIES(_state, _field)  \
-DEFINE_BLOCK_PROPERTIES(_state, _field.conf), \
-DEFINE_BLOCK_CHS_PROPERTIES(_state, _field.conf), \
-DEFINE_PROP_STRING(serial, _state, _field.serial),  \
-DEFINE_PROP_BIT(config-wce, _state, _field.config_wce, 0, true),\
-DEFINE_PROP_BIT(scsi, _state, _field.scsi, 0, true),\
-DEFINE_PROP_IOTHREAD(x-iothread, _state, _field.iothread)
+#define DEFINE_VIRTIO_BLK_PROPERTIES_LINUX(_state, _field) \
+DEFINE_PROP_BIT(scsi, _state, _field.scsi, 0, true),
 #else
+#define DEFINE_VIRTIO_BLK_PROPERTIES_LINUX(_state, _field)
+#endif
+
 #define DEFINE_VIRTIO_BLK_PROPERTIES(_state, _field)  \
+DEFINE_VIRTIO_BLK_PROPERTIES_LINUX(_state, _field)\
 DEFINE_BLOCK_PROPERTIES(_state, _field.conf), \
 DEFINE_BLOCK_CHS_PROPERTIES(_state, _field.conf), \
 DEFINE_PROP_STRING(serial, _state, _field.serial),  \
 DEFINE_PROP_BIT(config-wce, _state, _field.config_wce, 0, true),\
 DEFINE_PROP_IOTHREAD(x-iothread, _state, _field.iothread)
-#endif /* __linux__ */
 
 void virtio_blk_set_conf(DeviceState *dev, VirtIOBlkConf *blk);
 
-- 
1.9.3




[Qemu-devel] [PULL for-2.1 08/24] virtio: fix virtio-blk child refcount in transports

2014-07-01 Thread Stefan Hajnoczi
object_initialize() leaves the object with a refcount of 1.
object_property_add_child() adds its own reference which is dropped
again when the property is deleted.

The upshot of this is that we always have a refcount = 1.  Upon hot
unplug the virtio-blk child is not finalized!

Drop our reference after the child property has been added to the
parent.

Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
Reviewed-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---
 hw/s390x/s390-virtio-bus.c | 1 +
 hw/s390x/virtio-ccw.c  | 1 +
 hw/virtio/virtio-pci.c | 1 +
 3 files changed, 3 insertions(+)

diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c
index 38984ab..3438a88 100644
--- a/hw/s390x/s390-virtio-bus.c
+++ b/hw/s390x/s390-virtio-bus.c
@@ -179,6 +179,7 @@ static void s390_virtio_blk_instance_init(Object *obj)
 VirtIOBlkS390 *dev = VIRTIO_BLK_S390(obj);
 object_initialize(dev-vdev, sizeof(dev-vdev), TYPE_VIRTIO_BLK);
 object_property_add_child(obj, virtio-backend, OBJECT(dev-vdev), NULL);
+object_unref(OBJECT(dev-vdev));
 qdev_alias_all_properties(DEVICE(dev-vdev), obj);
 }
 
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index 9fa6f32..0553fea 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -813,6 +813,7 @@ static void virtio_ccw_blk_instance_init(Object *obj)
 VirtIOBlkCcw *dev = VIRTIO_BLK_CCW(obj);
 object_initialize(dev-vdev, sizeof(dev-vdev), TYPE_VIRTIO_BLK);
 object_property_add_child(obj, virtio-backend, OBJECT(dev-vdev), NULL);
+object_unref(OBJECT(dev-vdev));
 qdev_alias_all_properties(DEVICE(dev-vdev), obj);
 }
 
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 7359d8d..d41b864 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1101,6 +1101,7 @@ static void virtio_blk_pci_instance_init(Object *obj)
 VirtIOBlkPCI *dev = VIRTIO_BLK_PCI(obj);
 object_initialize(dev-vdev, sizeof(dev-vdev), TYPE_VIRTIO_BLK);
 object_property_add_child(obj, virtio-backend, OBJECT(dev-vdev), NULL);
+object_unref(OBJECT(dev-vdev));
 qdev_alias_all_properties(DEVICE(dev-vdev), obj);
 }
 
-- 
1.9.3




[Qemu-devel] [PULL for-2.1 04/24] virtio-blk: move x-data-plane qdev property to virtio-blk.h

2014-07-01 Thread Stefan Hajnoczi
Move the x-data-plane property.  Originally it was outside since not
every transport may wish to support dataplane.  But that makes little
sense when we have a dedicated CONFIG_VIRTIO_BLK_DATA_PLANE ifdef
already.

This move makes it easier to switch to property aliases in the next
patch.

Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
Reviewed-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---
 hw/s390x/virtio-ccw.c  | 3 ---
 hw/virtio/virtio-pci.c | 3 ---
 include/hw/virtio/virtio-blk.h | 8 
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index 05656a2..d7ff0a0 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -1403,9 +1403,6 @@ static Property virtio_ccw_blk_properties[] = {
 DEFINE_VIRTIO_BLK_PROPERTIES(VirtIOBlkCcw, blk),
 DEFINE_PROP_BIT(ioeventfd, VirtioCcwDevice, flags,
 VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
-#ifdef CONFIG_VIRTIO_BLK_DATA_PLANE
-DEFINE_PROP_BIT(x-data-plane, VirtIOBlkCcw, blk.data_plane, 0, false),
-#endif
 DEFINE_PROP_END_OF_LIST(),
 };
 
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 317324f..653d74e 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1066,9 +1066,6 @@ static Property virtio_blk_pci_properties[] = {
 DEFINE_PROP_BIT(ioeventfd, VirtIOPCIProxy, flags,
 VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true),
 DEFINE_PROP_UINT32(vectors, VirtIOPCIProxy, nvectors, 2),
-#ifdef CONFIG_VIRTIO_BLK_DATA_PLANE
-DEFINE_PROP_BIT(x-data-plane, VirtIOBlkPCI, blk.data_plane, 0, false),
-#endif
 DEFINE_VIRTIO_BLK_FEATURES(VirtIOPCIProxy, host_features),
 DEFINE_VIRTIO_BLK_PROPERTIES(VirtIOBlkPCI, blk),
 DEFINE_PROP_END_OF_LIST(),
diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h
index ee43f7a..1d80bcc 100644
--- a/include/hw/virtio/virtio-blk.h
+++ b/include/hw/virtio/virtio-blk.h
@@ -162,8 +162,16 @@ typedef struct VirtIOBlockReq {
 #define DEFINE_VIRTIO_BLK_PROPERTIES_LINUX(_state, _field)
 #endif
 
+#ifdef CONFIG_VIRTIO_BLK_DATA_PLANE
+#define DEFINE_VIRTIO_BLK_PROPERTIES_DATA_PLANE(_state, _field) \
+DEFINE_PROP_BIT(x-data-plane, _state, _field.data_plane, 0, false),
+#else
+#define DEFINE_VIRTIO_BLK_PROPERTIES_DATA_PLANE(_state, _field)
+#endif
+
 #define DEFINE_VIRTIO_BLK_PROPERTIES(_state, _field)  \
 DEFINE_VIRTIO_BLK_PROPERTIES_LINUX(_state, _field)\
+DEFINE_VIRTIO_BLK_PROPERTIES_DATA_PLANE(_state, _field)   \
 DEFINE_BLOCK_PROPERTIES(_state, _field.conf), \
 DEFINE_BLOCK_CHS_PROPERTIES(_state, _field.conf), \
 DEFINE_PROP_STRING(serial, _state, _field.serial),  \
-- 
1.9.3




[Qemu-devel] [PULL for-2.1 05/24] qdev: add qdev_alias_all_properties()

2014-07-01 Thread Stefan Hajnoczi
The qdev_alias_all_properties() function creates QOM alias properties
for each qdev property on a DeviceState.  This is useful for parent
objects that wish to forward property accesses to their children.

Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
Reviewed-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---
 hw/core/qdev.c   | 21 +
 include/hw/qdev-properties.h |  2 ++
 2 files changed, 23 insertions(+)

diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index d1eba3c..732e729 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -780,6 +780,27 @@ void qdev_property_add_static(DeviceState *dev, Property 
*prop,
 }
 }
 
+/* @qdev_alias_all_properties - Add alias properties to the source object for
+ * all qdev properties on the target DeviceState.
+ */
+void qdev_alias_all_properties(DeviceState *target, Object *source)
+{
+ObjectClass *class;
+Property *prop;
+
+class = object_get_class(OBJECT(target));
+do {
+DeviceClass *dc = DEVICE_CLASS(class);
+
+for (prop = dc-props; prop  prop-name; prop++) {
+object_property_add_alias(source, prop-name,
+  OBJECT(target), prop-name,
+  error_abort);
+}
+class = object_class_get_parent(class);
+} while (class != object_class_by_name(TYPE_DEVICE));
+}
+
 static bool device_get_realized(Object *obj, Error **errp)
 {
 DeviceState *dev = DEVICE(obj);
diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
index c962b6b..3726bf3 100644
--- a/include/hw/qdev-properties.h
+++ b/include/hw/qdev-properties.h
@@ -193,6 +193,8 @@ void error_set_from_qdev_prop_error(Error **errp, int ret, 
DeviceState *dev,
  */
 void qdev_property_add_static(DeviceState *dev, Property *prop, Error **errp);
 
+void qdev_alias_all_properties(DeviceState *target, Object *source);
+
 /**
  * @qdev_prop_set_after_realize:
  * @dev: device
-- 
1.9.3




[Qemu-devel] [PULL for-2.1 01/24] qom: add object_property_add_alias()

2014-07-01 Thread Stefan Hajnoczi
Sometimes an object needs to present a property which is actually on
another object, or it needs to provide an alias name for an existing
property.

Examples:
  a.foo - b.foo
  a.old_name - a.new_name

The new object_property_add_alias() API allows objects to alias a
property on the same object or another object.  The source and target
names can be different.

Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
Reviewed-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---
 include/qom/object.h | 20 
 qom/object.c | 51 +++
 2 files changed, 71 insertions(+)

diff --git a/include/qom/object.h b/include/qom/object.h
index b882ccc..44c513f 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -1231,6 +1231,26 @@ void object_property_add_uint64_ptr(Object *obj, const 
char *name,
 const uint64_t *v, Error **Errp);
 
 /**
+ * object_property_add_alias:
+ * @obj: the object to add a property to
+ * @name: the name of the property
+ * @target_obj: the object to forward property access to
+ * @target_name: the name of the property on the forwarded object
+ * @errp: if an error occurs, a pointer to an area to store the error
+ *
+ * Add an alias for a property on an object.  This function will add a property
+ * of the same type as the forwarded property.
+ *
+ * The caller must ensure that code@target_obj/code stays alive as long as
+ * this property exists.  In the case of a child object or an alias on the same
+ * object this will be the case.  For aliases to other objects the caller is
+ * responsible for taking a reference.
+ */
+void object_property_add_alias(Object *obj, const char *name,
+   Object *target_obj, const char *target_name,
+   Error **errp);
+
+/**
  * object_child_foreach:
  * @obj: the object whose children will be navigated
  * @fn: the iterator function to be called
diff --git a/qom/object.c b/qom/object.c
index 3876618..a760514 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1550,6 +1550,57 @@ void object_property_add_uint64_ptr(Object *obj, const 
char *name,
 NULL, NULL, (void *)v, errp);
 }
 
+typedef struct {
+Object *target_obj;
+const char *target_name;
+} AliasProperty;
+
+static void property_get_alias(Object *obj, struct Visitor *v, void *opaque,
+   const char *name, Error **errp)
+{
+AliasProperty *prop = opaque;
+
+object_property_get(prop-target_obj, v, prop-target_name, errp);
+}
+
+static void property_set_alias(Object *obj, struct Visitor *v, void *opaque,
+   const char *name, Error **errp)
+{
+AliasProperty *prop = opaque;
+
+object_property_set(prop-target_obj, v, prop-target_name, errp);
+}
+
+static void property_release_alias(Object *obj, const char *name, void *opaque)
+{
+AliasProperty *prop = opaque;
+
+g_free(prop);
+}
+
+void object_property_add_alias(Object *obj, const char *name,
+   Object *target_obj, const char *target_name,
+   Error **errp)
+{
+AliasProperty *prop;
+ObjectProperty *target_prop;
+
+target_prop = object_property_find(target_obj, target_name, errp);
+if (!target_prop) {
+return;
+}
+
+prop = g_malloc(sizeof(*prop));
+prop-target_obj = target_obj;
+prop-target_name = target_name;
+
+object_property_add(obj, name, target_prop-type,
+property_get_alias,
+property_set_alias,
+property_release_alias,
+prop, errp);
+}
+
 static void object_instance_init(Object *obj)
 {
 object_property_add_str(obj, type, qdev_get_type, NULL, NULL);
-- 
1.9.3




[Qemu-devel] [PULL for-2.1 12/24] virtio-blk: remove need for explicit x-data-plane=on option

2014-07-01 Thread Stefan Hajnoczi
The x-data-plane=on|off option is no longer useful because the
iothread=iothread option conveys the same information plus which
IOThread to use.

Do not delete x-data-plane=on|off yet as a convenience to people using
this legacy experimental option.  We will drop it in QEMU 2.2.

Instead, turn on data-plane when either x-data-plane=on or
iothread=iothread are used.  The following command-line uses
data-plane:

  qemu -device virtio-blk-pci,iothread=foo,drive=drive0

Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
---
 hw/block/dataplane/virtio-blk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
index f6e1a5d..4c5ba18 100644
--- a/hw/block/dataplane/virtio-blk.c
+++ b/hw/block/dataplane/virtio-blk.c
@@ -132,7 +132,7 @@ void virtio_blk_data_plane_create(VirtIODevice *vdev, 
VirtIOBlkConf *blk,
 
 *dataplane = NULL;
 
-if (!blk-data_plane) {
+if (!blk-data_plane  !blk-iothread) {
 return;
 }
 
-- 
1.9.3




[Qemu-devel] [PULL for-2.1 06/24] virtio-blk: use aliases instead of duplicate qdev properties

2014-07-01 Thread Stefan Hajnoczi
virtio-blk-pci, virtio-blk-s390, and virtio-blk-ccw all duplicate the
qdev properties of their VirtIOBlock child.  This approach does not work
well with string or pointer properties since we must be careful about
leaking or double-freeing them.

Use the QOM alias property to forward property accesses to the
VirtIOBlock child.  This way no duplication is necessary.

Remember to stop calling virtio_blk_set_conf() so that we don't clobber
the values already set on the VirtIOBlock instance.

Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
Reviewed-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---
 hw/s390x/s390-virtio-bus.c | 9 +
 hw/s390x/s390-virtio-bus.h | 1 -
 hw/s390x/virtio-ccw.c  | 3 +--
 hw/s390x/virtio-ccw.h  | 1 -
 hw/virtio/virtio-pci.c | 3 +--
 hw/virtio/virtio-pci.h | 1 -
 6 files changed, 3 insertions(+), 15 deletions(-)

diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c
index 7c8c81b..38984ab 100644
--- a/hw/s390x/s390-virtio-bus.c
+++ b/hw/s390x/s390-virtio-bus.c
@@ -167,7 +167,6 @@ static int s390_virtio_blk_init(VirtIOS390Device *s390_dev)
 {
 VirtIOBlkS390 *dev = VIRTIO_BLK_S390(s390_dev);
 DeviceState *vdev = DEVICE(dev-vdev);
-virtio_blk_set_conf(vdev, (dev-blk));
 qdev_set_parent_bus(vdev, BUS(s390_dev-bus));
 if (qdev_init(vdev)  0) {
 return -1;
@@ -180,6 +179,7 @@ static void s390_virtio_blk_instance_init(Object *obj)
 VirtIOBlkS390 *dev = VIRTIO_BLK_S390(obj);
 object_initialize(dev-vdev, sizeof(dev-vdev), TYPE_VIRTIO_BLK);
 object_property_add_child(obj, virtio-backend, OBJECT(dev-vdev), NULL);
+qdev_alias_all_properties(DEVICE(dev-vdev), obj);
 }
 
 static int s390_virtio_serial_init(VirtIOS390Device *s390_dev)
@@ -513,18 +513,11 @@ static const TypeInfo s390_virtio_net = {
 .class_init= s390_virtio_net_class_init,
 };
 
-static Property s390_virtio_blk_properties[] = {
-DEFINE_VIRTIO_BLK_PROPERTIES(VirtIOBlkS390, blk),
-DEFINE_PROP_END_OF_LIST(),
-};
-
 static void s390_virtio_blk_class_init(ObjectClass *klass, void *data)
 {
-DeviceClass *dc = DEVICE_CLASS(klass);
 VirtIOS390DeviceClass *k = VIRTIO_S390_DEVICE_CLASS(klass);
 
 k-init = s390_virtio_blk_init;
-dc-props = s390_virtio_blk_properties;
 }
 
 static const TypeInfo s390_virtio_blk = {
diff --git a/hw/s390x/s390-virtio-bus.h b/hw/s390x/s390-virtio-bus.h
index ac81bd8..ffd0df7 100644
--- a/hw/s390x/s390-virtio-bus.h
+++ b/hw/s390x/s390-virtio-bus.h
@@ -124,7 +124,6 @@ void s390_virtio_reset_idx(VirtIOS390Device *dev);
 typedef struct VirtIOBlkS390 {
 VirtIOS390Device parent_obj;
 VirtIOBlock vdev;
-VirtIOBlkConf blk;
 } VirtIOBlkS390;
 
 /* virtio-scsi-s390 */
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index d7ff0a0..9fa6f32 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -800,7 +800,6 @@ static int virtio_ccw_blk_init(VirtioCcwDevice *ccw_dev)
 {
 VirtIOBlkCcw *dev = VIRTIO_BLK_CCW(ccw_dev);
 DeviceState *vdev = DEVICE(dev-vdev);
-virtio_blk_set_conf(vdev, (dev-blk));
 qdev_set_parent_bus(vdev, BUS(ccw_dev-bus));
 if (qdev_init(vdev)  0) {
 return -1;
@@ -814,6 +813,7 @@ static void virtio_ccw_blk_instance_init(Object *obj)
 VirtIOBlkCcw *dev = VIRTIO_BLK_CCW(obj);
 object_initialize(dev-vdev, sizeof(dev-vdev), TYPE_VIRTIO_BLK);
 object_property_add_child(obj, virtio-backend, OBJECT(dev-vdev), NULL);
+qdev_alias_all_properties(DEVICE(dev-vdev), obj);
 }
 
 static int virtio_ccw_serial_init(VirtioCcwDevice *ccw_dev)
@@ -1400,7 +1400,6 @@ static const TypeInfo virtio_ccw_net = {
 static Property virtio_ccw_blk_properties[] = {
 DEFINE_PROP_STRING(devno, VirtioCcwDevice, bus_id),
 DEFINE_VIRTIO_BLK_FEATURES(VirtioCcwDevice, host_features[0]),
-DEFINE_VIRTIO_BLK_PROPERTIES(VirtIOBlkCcw, blk),
 DEFINE_PROP_BIT(ioeventfd, VirtioCcwDevice, flags,
 VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
 DEFINE_PROP_END_OF_LIST(),
diff --git a/hw/s390x/virtio-ccw.h b/hw/s390x/virtio-ccw.h
index b8b8a8a..5a1f16e 100644
--- a/hw/s390x/virtio-ccw.h
+++ b/hw/s390x/virtio-ccw.h
@@ -144,7 +144,6 @@ typedef struct VHostSCSICcw {
 typedef struct VirtIOBlkCcw {
 VirtioCcwDevice parent_obj;
 VirtIOBlock vdev;
-VirtIOBlkConf blk;
 } VirtIOBlkCcw;
 
 /* virtio-balloon-ccw */
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 653d74e..7359d8d 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1067,7 +1067,6 @@ static Property virtio_blk_pci_properties[] = {
 VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true),
 DEFINE_PROP_UINT32(vectors, VirtIOPCIProxy, nvectors, 2),
 DEFINE_VIRTIO_BLK_FEATURES(VirtIOPCIProxy, host_features),
-DEFINE_VIRTIO_BLK_PROPERTIES(VirtIOBlkPCI, blk),
 DEFINE_PROP_END_OF_LIST(),
 };
 
@@ -1075,7 +1074,6 @@ static int virtio_blk_pci_init(VirtIOPCIProxy *vpci_dev)
 {
 VirtIOBlkPCI *dev = 

[Qemu-devel] [PULL for-2.1 09/24] virtio-blk: move qdev properties into virtio-blk.c

2014-07-01 Thread Stefan Hajnoczi
There is no need to make DEFINE_VIRTIO_BLK_PROPERTIES() public.  Inline
it into virtio-blk.c so it cannot be used by mistake from other source
files.

Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
Reviewed-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---
 hw/block/virtio-blk.c  | 12 +++-
 include/hw/virtio/virtio-blk.h | 23 ---
 2 files changed, 11 insertions(+), 24 deletions(-)

diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index f1a667c..b8d51bb 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -785,7 +785,17 @@ static void virtio_blk_device_unrealize(DeviceState *dev, 
Error **errp)
 }
 
 static Property virtio_blk_properties[] = {
-DEFINE_VIRTIO_BLK_PROPERTIES(VirtIOBlock, blk),
+DEFINE_BLOCK_PROPERTIES(VirtIOBlock, blk.conf),
+DEFINE_BLOCK_CHS_PROPERTIES(VirtIOBlock, blk.conf),
+DEFINE_PROP_STRING(serial, VirtIOBlock, blk.serial),
+DEFINE_PROP_BIT(config-wce, VirtIOBlock, blk.config_wce, 0, true),
+DEFINE_PROP_IOTHREAD(x-iothread, VirtIOBlock, blk.iothread),
+#ifdef __linux__
+DEFINE_PROP_BIT(scsi, VirtIOBlock, blk.scsi, 0, true),
+#endif
+#ifdef CONFIG_VIRTIO_BLK_DATA_PLANE
+DEFINE_PROP_BIT(x-data-plane, VirtIOBlock, blk.data_plane, 0, false),
+#endif
 DEFINE_PROP_END_OF_LIST(),
 };
 
diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h
index 52e5add..223530e 100644
--- a/include/hw/virtio/virtio-blk.h
+++ b/include/hw/virtio/virtio-blk.h
@@ -155,29 +155,6 @@ typedef struct VirtIOBlockReq {
 #define DEFINE_VIRTIO_BLK_FEATURES(_state, _field) \
 DEFINE_VIRTIO_COMMON_FEATURES(_state, _field)
 
-#ifdef __linux__
-#define DEFINE_VIRTIO_BLK_PROPERTIES_LINUX(_state, _field) \
-DEFINE_PROP_BIT(scsi, _state, _field.scsi, 0, true),
-#else
-#define DEFINE_VIRTIO_BLK_PROPERTIES_LINUX(_state, _field)
-#endif
-
-#ifdef CONFIG_VIRTIO_BLK_DATA_PLANE
-#define DEFINE_VIRTIO_BLK_PROPERTIES_DATA_PLANE(_state, _field) \
-DEFINE_PROP_BIT(x-data-plane, _state, _field.data_plane, 0, false),
-#else
-#define DEFINE_VIRTIO_BLK_PROPERTIES_DATA_PLANE(_state, _field)
-#endif
-
-#define DEFINE_VIRTIO_BLK_PROPERTIES(_state, _field)  \
-DEFINE_VIRTIO_BLK_PROPERTIES_LINUX(_state, _field)\
-DEFINE_VIRTIO_BLK_PROPERTIES_DATA_PLANE(_state, _field)   \
-DEFINE_BLOCK_PROPERTIES(_state, _field.conf), \
-DEFINE_BLOCK_CHS_PROPERTIES(_state, _field.conf), \
-DEFINE_PROP_STRING(serial, _state, _field.serial),  \
-DEFINE_PROP_BIT(config-wce, _state, _field.config_wce, 0, true),\
-DEFINE_PROP_IOTHREAD(x-iothread, _state, _field.iothread)
-
 int virtio_blk_handle_scsi_req(VirtIOBlock *blk,
VirtQueueElement *elem);
 
-- 
1.9.3




[Qemu-devel] [PULL for-2.1 07/24] virtio-blk: drop virtio_blk_set_conf()

2014-07-01 Thread Stefan Hajnoczi
This function is no longer used since parent objects now use child
aliases to set the VirtIOBlkConf directly.

Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
Reviewed-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---
 hw/block/virtio-blk.c  | 6 --
 include/hw/virtio/virtio-blk.h | 2 --
 2 files changed, 8 deletions(-)

diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index e59ebc9..f1a667c 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -677,12 +677,6 @@ static const BlockDevOps virtio_block_ops = {
 .resize_cb = virtio_blk_resize,
 };
 
-void virtio_blk_set_conf(DeviceState *dev, VirtIOBlkConf *blk)
-{
-VirtIOBlock *s = VIRTIO_BLK(dev);
-memcpy((s-blk), blk, sizeof(struct VirtIOBlkConf));
-}
-
 #ifdef CONFIG_VIRTIO_BLK_DATA_PLANE
 /* Disable dataplane thread during live migration since it does not
  * update the dirty memory bitmap yet.
diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h
index 1d80bcc..52e5add 100644
--- a/include/hw/virtio/virtio-blk.h
+++ b/include/hw/virtio/virtio-blk.h
@@ -178,8 +178,6 @@ typedef struct VirtIOBlockReq {
 DEFINE_PROP_BIT(config-wce, _state, _field.config_wce, 0, true),\
 DEFINE_PROP_IOTHREAD(x-iothread, _state, _field.iothread)
 
-void virtio_blk_set_conf(DeviceState *dev, VirtIOBlkConf *blk);
-
 int virtio_blk_handle_scsi_req(VirtIOBlock *blk,
VirtQueueElement *elem);
 
-- 
1.9.3




[Qemu-devel] [PULL for-2.1 03/24] dataplane: bail out on unsupported transport

2014-07-01 Thread Stefan Hajnoczi
From: Cornelia Huck cornelia.h...@de.ibm.com

If the virtio transport does not support notifiers (like s390-virtio),
we can't use dataplane. Bail out early and let the user know what is
wrong.

Signed-off-by: Cornelia Huck cornelia.h...@de.ibm.com
Reviewed-by: Stefan Hajnoczi stefa...@redhat.com
Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
---
 hw/block/dataplane/virtio-blk.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
index 09bd2c7..f6e1a5d 100644
--- a/hw/block/dataplane/virtio-blk.c
+++ b/hw/block/dataplane/virtio-blk.c
@@ -127,6 +127,8 @@ void virtio_blk_data_plane_create(VirtIODevice *vdev, 
VirtIOBlkConf *blk,
 VirtIOBlockDataPlane *s;
 VirtIOBlock *vblk = VIRTIO_BLK(vdev);
 Error *local_err = NULL;
+BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev)));
+VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
 
 *dataplane = NULL;
 
@@ -134,6 +136,14 @@ void virtio_blk_data_plane_create(VirtIODevice *vdev, 
VirtIOBlkConf *blk,
 return;
 }
 
+/* Don't try if transport does not support notifiers. */
+if (!k-set_guest_notifiers || !k-set_host_notifier) {
+error_setg(errp,
+   device is incompatible with x-data-plane 
+   (transport does not support notifiers));
+return;
+}
+
 /* If dataplane is (re-)enabled while the guest is running there could be
  * block jobs that can conflict.
  */
-- 
1.9.3




[Qemu-devel] [PULL for-2.1 14/24] iotests: Simplify qemu-iotests-quick.sh

2014-07-01 Thread Stefan Hajnoczi
From: Max Reitz mre...@redhat.com

As of the iotests: Allow out-of-tree run series, the qemu-iotests may
(and should) be run directly in the build tree and will then guess the
binary paths themselves. Therefore, qemu-iotests-quick.sh does not need
to (and should not) enter the source path anymore; also, it does not
need to specify the binaries because check will guess them
automatically.

As a side-effect, tests using qemu may now be added to the quick group.

Signed-off-by: Max Reitz mre...@redhat.com
Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
---
 tests/qemu-iotests-quick.sh | 12 +---
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/tests/qemu-iotests-quick.sh b/tests/qemu-iotests-quick.sh
index c449e8a..8a9a4c6 100755
--- a/tests/qemu-iotests-quick.sh
+++ b/tests/qemu-iotests-quick.sh
@@ -1,16 +1,6 @@
 #!/bin/sh
 
-# We don't know which of the system emulator binaries there is (or if there is
-# any at all), so the 'quick' group doesn't contain any tests that require
-# running qemu proper. Assign a fake binary name so that qemu-iotests doesn't
-# complain about the missing binary.
-export QEMU_PROG=this_should_be_unused
-
-export QEMU_IMG_PROG=$(pwd)/qemu-img
-export QEMU_IO_PROG=$(pwd)/qemu-io
-export QEMU_NBD_PROG=$(pwd)/qemu-nbd
-
-cd $SRC_PATH/tests/qemu-iotests
+cd tests/qemu-iotests
 
 ret=0
 ./check -T -nocache -qcow2 -g quick || ret=1
-- 
1.9.3




[Qemu-devel] [PULL for-2.1 11/24] qdev: drop iothread property type

2014-07-01 Thread Stefan Hajnoczi
The iothread property type is no longer used and can be removed.

Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
---
 hw/core/qdev-properties-system.c | 50 
 include/hw/qdev-properties.h |  3 ---
 2 files changed, 53 deletions(-)

diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index 52c2f8a..8e140af 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -385,56 +385,6 @@ void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd)
 nd-instantiated = 1;
 }
 
-/* --- iothread --- */
-
-static char *print_iothread(void *ptr)
-{
-return iothread_get_id(ptr);
-}
-
-static int parse_iothread(DeviceState *dev, const char *str, void **ptr)
-{
-IOThread *iothread;
-
-iothread = iothread_find(str);
-if (!iothread) {
-return -ENOENT;
-}
-object_ref(OBJECT(iothread));
-*ptr = iothread;
-return 0;
-}
-
-static void get_iothread(Object *obj, struct Visitor *v, void *opaque,
- const char *name, Error **errp)
-{
-get_pointer(obj, v, opaque, print_iothread, name, errp);
-}
-
-static void set_iothread(Object *obj, struct Visitor *v, void *opaque,
- const char *name, Error **errp)
-{
-set_pointer(obj, v, opaque, parse_iothread, name, errp);
-}
-
-static void release_iothread(Object *obj, const char *name, void *opaque)
-{
-DeviceState *dev = DEVICE(obj);
-Property *prop = opaque;
-IOThread **ptr = qdev_get_prop_ptr(dev, prop);
-
-if (*ptr) {
-object_unref(OBJECT(*ptr));
-}
-}
-
-PropertyInfo qdev_prop_iothread = {
-.name = iothread,
-.get = get_iothread,
-.set = set_iothread,
-.release = release_iothread,
-};
-
 static int qdev_add_one_global(QemuOpts *opts, void *opaque)
 {
 GlobalProperty *g;
diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
index 3726bf3..77fe3a1 100644
--- a/include/hw/qdev-properties.h
+++ b/include/hw/qdev-properties.h
@@ -22,7 +22,6 @@ extern PropertyInfo qdev_prop_bios_chs_trans;
 extern PropertyInfo qdev_prop_drive;
 extern PropertyInfo qdev_prop_netdev;
 extern PropertyInfo qdev_prop_vlan;
-extern PropertyInfo qdev_prop_iothread;
 extern PropertyInfo qdev_prop_pci_devfn;
 extern PropertyInfo qdev_prop_blocksize;
 extern PropertyInfo qdev_prop_pci_host_devaddr;
@@ -143,8 +142,6 @@ extern PropertyInfo qdev_prop_arraylen;
 DEFINE_PROP(_n, _s, _f, qdev_prop_vlan, NICPeers)
 #define DEFINE_PROP_DRIVE(_n, _s, _f) \
 DEFINE_PROP(_n, _s, _f, qdev_prop_drive, BlockDriverState *)
-#define DEFINE_PROP_IOTHREAD(_n, _s, _f) \
-DEFINE_PROP(_n, _s, _f, qdev_prop_iothread, IOThread *)
 #define DEFINE_PROP_MACADDR(_n, _s, _f) \
 DEFINE_PROP(_n, _s, _f, qdev_prop_macaddr, MACAddr)
 #define DEFINE_PROP_LOSTTICKPOLICY(_n, _s, _f, _d) \
-- 
1.9.3




[Qemu-devel] [PULL for-2.1 15/24] iotests: Add qemu tests to quick group

2014-07-01 Thread Stefan Hajnoczi
From: Max Reitz mre...@redhat.com

Now that qemu-iotests-quick.sh supports tests using the qemu binary, we
are free to add such tests to the quick group.

Signed-off-by: Max Reitz mre...@redhat.com
Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
---
 tests/qemu-iotests/group | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
index e3dc4e8..7a2bfca 100644
--- a/tests/qemu-iotests/group
+++ b/tests/qemu-iotests/group
@@ -51,7 +51,7 @@
 042 rw auto quick
 043 rw auto backing
 044 rw auto
-045 rw auto
+045 rw auto quick
 046 rw auto aio
 047 rw auto
 048 img auto quick
@@ -71,13 +71,13 @@
 062 rw auto quick
 063 rw auto quick
 064 rw auto quick
-065 rw auto
+065 rw auto quick
 066 rw auto quick
-067 rw auto
-068 rw auto
+067 rw auto quick
+068 rw auto quick
 069 rw auto quick
 070 rw auto quick
-071 rw auto
+071 rw auto quick
 072 rw auto quick
 073 rw auto quick
 074 rw auto quick
@@ -87,16 +87,16 @@
 078 rw auto
 079 rw auto
 080 rw auto
-081 rw auto
+081 rw auto quick
 082 rw auto quick
 083 rw auto
 084 img auto
 085 rw auto
 086 rw auto quick
-087 rw auto
+087 rw auto quick
 088 rw auto
 089 rw auto quick
 090 rw auto quick
-091 rw auto
+091 rw auto quick
 092 rw auto quick
-095 rw auto
+095 rw auto quick
-- 
1.9.3




[Qemu-devel] [PULL for-2.1 10/24] virtio-blk: replace x-iothread with iothread link property

2014-07-01 Thread Stefan Hajnoczi
Up until now -device virtio-blk-pci,x-iothread=id was used to assign
an IOThread.  This was a temporary solution while we cleaned up QOM link
properties.

This patch switches over to a QOM link property since it is now possible
to restrict the setter to unrealized instances and automatically unref
the IOThread when the virtio-blk-pci device is freed.

Since the iothread property is a QOM property and not a qdev property,
we must alias it explicitly for virtio-blk-pci, as well as CCW and
s390-virtio.

Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
---
 hw/block/virtio-blk.c  | 12 +++-
 hw/s390x/s390-virtio-bus.c |  2 ++
 hw/s390x/virtio-ccw.c  |  2 ++
 hw/virtio/virtio-pci.c |  2 ++
 4 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index b8d51bb..aec3146 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -784,12 +784,21 @@ static void virtio_blk_device_unrealize(DeviceState *dev, 
Error **errp)
 virtio_cleanup(vdev);
 }
 
+static void virtio_blk_instance_init(Object *obj)
+{
+VirtIOBlock *s = VIRTIO_BLK(obj);
+
+object_property_add_link(obj, iothread, TYPE_IOTHREAD,
+ (Object **)s-blk.iothread,
+ qdev_prop_allow_set_link_before_realize,
+ OBJ_PROP_LINK_UNREF_ON_RELEASE, NULL);
+}
+
 static Property virtio_blk_properties[] = {
 DEFINE_BLOCK_PROPERTIES(VirtIOBlock, blk.conf),
 DEFINE_BLOCK_CHS_PROPERTIES(VirtIOBlock, blk.conf),
 DEFINE_PROP_STRING(serial, VirtIOBlock, blk.serial),
 DEFINE_PROP_BIT(config-wce, VirtIOBlock, blk.config_wce, 0, true),
-DEFINE_PROP_IOTHREAD(x-iothread, VirtIOBlock, blk.iothread),
 #ifdef __linux__
 DEFINE_PROP_BIT(scsi, VirtIOBlock, blk.scsi, 0, true),
 #endif
@@ -821,6 +830,7 @@ static const TypeInfo virtio_device_info = {
 .name = TYPE_VIRTIO_BLK,
 .parent = TYPE_VIRTIO_DEVICE,
 .instance_size = sizeof(VirtIOBlock),
+.instance_init = virtio_blk_instance_init,
 .class_init = virtio_blk_class_init,
 };
 
diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c
index 3438a88..c0dc365 100644
--- a/hw/s390x/s390-virtio-bus.c
+++ b/hw/s390x/s390-virtio-bus.c
@@ -181,6 +181,8 @@ static void s390_virtio_blk_instance_init(Object *obj)
 object_property_add_child(obj, virtio-backend, OBJECT(dev-vdev), NULL);
 object_unref(OBJECT(dev-vdev));
 qdev_alias_all_properties(DEVICE(dev-vdev), obj);
+object_property_add_alias(obj, iothread, OBJECT(dev-vdev),iothread,
+  error_abort);
 }
 
 static int s390_virtio_serial_init(VirtIOS390Device *s390_dev)
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index 0553fea..c279968 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -815,6 +815,8 @@ static void virtio_ccw_blk_instance_init(Object *obj)
 object_property_add_child(obj, virtio-backend, OBJECT(dev-vdev), NULL);
 object_unref(OBJECT(dev-vdev));
 qdev_alias_all_properties(DEVICE(dev-vdev), obj);
+object_property_add_alias(obj, iothread, OBJECT(dev-vdev),iothread,
+  error_abort);
 }
 
 static int virtio_ccw_serial_init(VirtioCcwDevice *ccw_dev)
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index d41b864..3c42cda 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1103,6 +1103,8 @@ static void virtio_blk_pci_instance_init(Object *obj)
 object_property_add_child(obj, virtio-backend, OBJECT(dev-vdev), NULL);
 object_unref(OBJECT(dev-vdev));
 qdev_alias_all_properties(DEVICE(dev-vdev), obj);
+object_property_add_alias(obj, iothread, OBJECT(dev-vdev),iothread,
+  error_abort);
 }
 
 static const TypeInfo virtio_blk_pci_info = {
-- 
1.9.3




[Qemu-devel] [PULL for-2.1 13/24] qemu-img create: add 'nocow' option

2014-07-01 Thread Stefan Hajnoczi
From: Chunyan Liu cy...@suse.com

Add 'nocow' option so that users could have a chance to set NOCOW flag to
newly created files. It's useful on btrfs file system to enhance performance.

Btrfs has low performance when hosting VM images, even more when the guest
in those VM are also using btrfs as file system. One way to mitigate this bad
performance is to turn off COW attributes on VM files. Generally, there are
two ways to turn off NOCOW on btrfs: a) by mounting fs with nodatacow, then
all newly created files will be NOCOW. b) per file. Add the NOCOW file
attribute. It could only be done to empty or new files.

This patch tries the second way, according to the option, it could add NOCOW
per file.

For most block drivers, since the create file step is in raw-posix.c, so we
can do setting NOCOW flag ioctl in raw-posix.c only.

But there are some exceptions, like block/vpc.c and block/vdi.c, they are
creating file by calling qemu_open directly. For them, do the same setting
NOCOW flag ioctl work in them separately.

[Fixed up 082.out due to the new 'nocow' creation option
--Stefan]

Signed-off-by: Chunyan Liu cy...@suse.com
Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
---
 block/qed.c|  6 +++---
 block/raw-posix.c  | 25 +
 block/vdi.c| 29 +
 block/vmdk.c   |  6 +++---
 block/vpc.c| 29 +
 include/block/block_int.h  |  1 +
 qemu-doc.texi  | 16 
 qemu-img.texi  | 16 
 tests/qemu-iotests/082.out | 24 
 9 files changed, 146 insertions(+), 6 deletions(-)

diff --git a/block/qed.c b/block/qed.c
index eddae92..b69374b 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -567,7 +567,7 @@ static void bdrv_qed_close(BlockDriverState *bs)
 static int qed_create(const char *filename, uint32_t cluster_size,
   uint64_t image_size, uint32_t table_size,
   const char *backing_file, const char *backing_fmt,
-  Error **errp)
+  QemuOpts *opts, Error **errp)
 {
 QEDHeader header = {
 .magic = QED_MAGIC,
@@ -586,7 +586,7 @@ static int qed_create(const char *filename, uint32_t 
cluster_size,
 int ret = 0;
 BlockDriverState *bs;
 
-ret = bdrv_create_file(filename, NULL, local_err);
+ret = bdrv_create_file(filename, opts, local_err);
 if (ret  0) {
 error_propagate(errp, local_err);
 return ret;
@@ -682,7 +682,7 @@ static int bdrv_qed_create(const char *filename, QemuOpts 
*opts, Error **errp)
 }
 
 ret = qed_create(filename, cluster_size, image_size, table_size,
- backing_file, backing_fmt, errp);
+ backing_file, backing_fmt, opts, errp);
 
 finish:
 g_free(backing_file);
diff --git a/block/raw-posix.c b/block/raw-posix.c
index dacf4fb..825a0c8 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -55,6 +55,9 @@
 #include linux/cdrom.h
 #include linux/fd.h
 #include linux/fs.h
+#ifndef FS_NOCOW_FL
+#define FS_NOCOW_FL 0x0080 /* Do not cow file */
+#endif
 #endif
 #ifdef CONFIG_FIEMAP
 #include linux/fiemap.h
@@ -1278,12 +1281,14 @@ static int raw_create(const char *filename, QemuOpts 
*opts, Error **errp)
 int fd;
 int result = 0;
 int64_t total_size = 0;
+bool nocow = false;
 
 strstart(filename, file:, filename);
 
 /* Read out options */
 total_size =
 qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0) / BDRV_SECTOR_SIZE;
+nocow = qemu_opt_get_bool(opts, BLOCK_OPT_NOCOW, false);
 
 fd = qemu_open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
0644);
@@ -1291,6 +1296,21 @@ static int raw_create(const char *filename, QemuOpts 
*opts, Error **errp)
 result = -errno;
 error_setg_errno(errp, -result, Could not create file);
 } else {
+if (nocow) {
+#ifdef __linux__
+/* Set NOCOW flag to solve performance issue on fs like btrfs.
+ * This is an optimisation. The FS_IOC_SETFLAGS ioctl return value
+ * will be ignored since any failure of this operation should not
+ * block the left work.
+ */
+int attr;
+if (ioctl(fd, FS_IOC_GETFLAGS, attr) == 0) {
+attr |= FS_NOCOW_FL;
+ioctl(fd, FS_IOC_SETFLAGS, attr);
+}
+#endif
+}
+
 if (ftruncate(fd, total_size * BDRV_SECTOR_SIZE) != 0) {
 result = -errno;
 error_setg_errno(errp, -result, Could not resize file);
@@ -1477,6 +1497,11 @@ static QemuOptsList raw_create_opts = {
 .type = QEMU_OPT_SIZE,
 .help = Virtual disk size
 },
+{
+.name = BLOCK_OPT_NOCOW,
+.type = QEMU_OPT_BOOL,
+.help = Turn off copy-on-write (valid only on btrfs)
+  

[Qemu-devel] [PULL for-2.1 17/24] block: make 'top' argument to block-commit optional

2014-07-01 Thread Stefan Hajnoczi
From: Jeff Cody jc...@redhat.com

Now that active layer block-commit is supported, the 'top' argument
no longer needs to be mandatory.

Change it to optional, with the default being the active layer in the
device chain.

[kwolf: Rebased and resolved conflict in tests/qemu-iotests/040]

Reviewed-by: Eric Blake ebl...@redhat.com
Reviewed-by: Benoit Canet ben...@irqsave.net
Signed-off-by: Jeff Cody jc...@redhat.com
Signed-off-by: Kevin Wolf kw...@redhat.com
Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
---
 blockdev.c | 16 ++--
 qapi/block-core.json   |  7 ---
 qmp-commands.hx|  5 +++--
 tests/qemu-iotests/040 | 28 ++--
 4 files changed, 39 insertions(+), 17 deletions(-)

diff --git a/blockdev.c b/blockdev.c
index 69b7c2a..79ce52b 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1913,7 +1913,8 @@ void qmp_block_stream(const char *device, bool has_base,
 }
 
 void qmp_block_commit(const char *device,
-  bool has_base, const char *base, const char *top,
+  bool has_base, const char *base,
+  bool has_top, const char *top,
   bool has_speed, int64_t speed,
   Error **errp)
 {
@@ -1932,6 +1933,11 @@ void qmp_block_commit(const char *device,
 /* drain all i/o before commits */
 bdrv_drain_all();
 
+/* Important Note:
+ *  libvirt relies on the DeviceNotFound error class in order to probe for
+ *  live commit feature versions; for this to work, we must make sure to
+ *  perform the device lookup before any generic errors that may occur in a
+ *  scenario in which all optional arguments are omitted. */
 bs = bdrv_find(device);
 if (!bs) {
 error_set(errp, QERR_DEVICE_NOT_FOUND, device);
@@ -1945,7 +1951,7 @@ void qmp_block_commit(const char *device,
 /* default top_bs is the active layer */
 top_bs = bs;
 
-if (top) {
+if (has_top  top) {
 if (strcmp(bs-filename, top) != 0) {
 top_bs = bdrv_find_backing_image(bs, top);
 }
@@ -1967,6 +1973,12 @@ void qmp_block_commit(const char *device,
 return;
 }
 
+/* Do not allow attempts to commit an image into itself */
+if (top_bs == base_bs) {
+error_setg(errp, cannot commit an image into itself);
+return;
+}
+
 if (top_bs == bs) {
 commit_active_start(bs, base_bs, speed, on_error, block_job_cb,
 bs, local_err);
diff --git a/qapi/block-core.json b/qapi/block-core.json
index faf394c..6a697f1 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -690,8 +690,9 @@
 # @base:   #optional The file name of the backing image to write data into.
 #If not specified, this is the deepest backing image
 #
-# @top:  The file name of the backing image within the image chain,
-#which contains the topmost data to be committed down.
+# @top:#optional The file name of the backing image within the image chain,
+#which contains the topmost data to be committed down. If
+#not specified, this is the active layer.
 #
 #If top == base, that is an error.
 #If top == active, the job will not be completed by itself,
@@ -719,7 +720,7 @@
 #
 ##
 { 'command': 'block-commit',
-  'data': { 'device': 'str', '*base': 'str', 'top': 'str',
+  'data': { 'device': 'str', '*base': 'str', '*top': 'str',
 '*speed': 'int' } }
 
 ##
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 1ea18b2..8c5fdb5 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -985,7 +985,7 @@ EQMP
 
 {
 .name   = block-commit,
-.args_type  = device:B,base:s?,top:s,speed:o?,
+.args_type  = device:B,base:s?,top:s?,speed:o?,
 .mhandler.cmd_new = qmp_marshal_input_block_commit,
 },
 
@@ -1003,7 +1003,8 @@ Arguments:
   If not specified, this is the deepest backing image
   (json-string, optional)
 - top:  The file name of the backing image within the image chain,
-  which contains the topmost data to be committed down.
+  which contains the topmost data to be committed down. If
+  not specified, this is the active layer. (json-string, optional)
 
   If top == base, that is an error.
   If top == active, the job will not be completed by itself,
diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040
index d166810..f1e16c1 100755
--- a/tests/qemu-iotests/040
+++ b/tests/qemu-iotests/040
@@ -35,11 +35,7 @@ test_img = os.path.join(iotests.test_dir, 'test.img')
 class ImageCommitTestCase(iotests.QMPTestCase):
 '''Abstract base class for image commit test cases'''
 
-def run_commit_test(self, top, base, need_ready=False):
-self.assert_no_active_block_jobs()
-result = self.vm.qmp('block-commit', device='drive0', top=top, 
base=base)
-

[Qemu-devel] [PULL for-2.1 22/24] block: add helper function to determine if a BDS is in a chain

2014-07-01 Thread Stefan Hajnoczi
From: Jeff Cody jc...@redhat.com

This is a small helper function, to determine if 'base' is in the
chain of BlockDriverState 'top'.  It returns true if it is in the chain,
and false otherwise.

If either argument is NULL, it will also return false.

Reviewed-by: Benoit Canet ben...@irqsave.net
Reviewed-by: Eric Blake ebl...@redhat.com
Signed-off-by: Jeff Cody jc...@redhat.com
Reviewed-by: Kevin Wolf kw...@redhat.com
Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
---
 block.c   | 11 +++
 include/block/block.h |  1 +
 2 files changed, 12 insertions(+)

diff --git a/block.c b/block.c
index c111c29..f45e63c 100644
--- a/block.c
+++ b/block.c
@@ -3774,6 +3774,17 @@ BlockDriverState *bdrv_lookup_bs(const char *device,
 return NULL;
 }
 
+/* If 'base' is in the same chain as 'top', return true. Otherwise,
+ * return false.  If either argument is NULL, return false. */
+bool bdrv_chain_contains(BlockDriverState *top, BlockDriverState *base)
+{
+while (top  top != base) {
+top = top-backing_hd;
+}
+
+return top != NULL;
+}
+
 BlockDriverState *bdrv_next(BlockDriverState *bs)
 {
 if (!bs) {
diff --git a/include/block/block.h b/include/block/block.h
index 7e92f54..29c9e50 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -403,6 +403,7 @@ BlockDeviceInfoList *bdrv_named_nodes_list(void);
 BlockDriverState *bdrv_lookup_bs(const char *device,
  const char *node_name,
  Error **errp);
+bool bdrv_chain_contains(BlockDriverState *top, BlockDriverState *base);
 BlockDriverState *bdrv_next(BlockDriverState *bs);
 void bdrv_iterate(void (*it)(void *opaque, BlockDriverState *bs),
   void *opaque);
-- 
1.9.3




[Qemu-devel] [PULL for-2.1 21/24] block: add QAPI command to allow live backing file change

2014-07-01 Thread Stefan Hajnoczi
From: Jeff Cody jc...@redhat.com

This allows a user to make a live change to the backing file recorded in
an open image.

The image file to modify can be specified 2 ways:

1) image filename
2) image node-name

Note: this does not cause the backing file itself to be reopened; it
merely changes the backing filename in the image file structure, and
in internal BDS structures.

It is the responsibility of the user to pass a filename string that
can be resolved when the image chain is reopened, and the filename
string is not validated.

A good analogy for this command is that it is a live version of
'qemu-img rebase -u', with respect to changing the backing file string.

[Jeff is offline so I respun this patch in his absence.  Dropped image
filename since using node-name is preferred and this is a new command.
No need to introduce the limitations of finding images by filename.
--Stefan]

Reviewed-by: Eric Blake ebl...@redhat.com
Reviewed-by: Kevin Wolf kw...@redhat.com
Signed-off-by: Jeff Cody jc...@redhat.com
Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
---
 blockdev.c   | 79 
 qapi/block-core.json | 26 +
 qmp-commands.hx  | 39 ++
 3 files changed, 144 insertions(+)

diff --git a/blockdev.c b/blockdev.c
index 79ce52b..57373d3 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2367,6 +2367,85 @@ void qmp_block_job_complete(const char *device, Error 
**errp)
 block_job_complete(job, errp);
 }
 
+void qmp_change_backing_file(const char *device,
+ const char *image_node_name,
+ const char *backing_file,
+ Error **errp)
+{
+BlockDriverState *bs = NULL;
+BlockDriverState *image_bs = NULL;
+Error *local_err = NULL;
+bool ro;
+int open_flags;
+int ret;
+
+/* find the top layer BDS of the chain */
+bs = bdrv_find(device);
+if (!bs) {
+error_set(errp, QERR_DEVICE_NOT_FOUND, device);
+return;
+}
+
+image_bs = bdrv_lookup_bs(NULL, image_node_name, local_err);
+if (local_err) {
+error_propagate(errp, local_err);
+return;
+}
+
+if (!image_bs) {
+error_setg(errp, image file not found);
+return;
+}
+
+if (bdrv_find_base(image_bs) == image_bs) {
+error_setg(errp, not allowing backing file change on an image 
+ without a backing file);
+return;
+}
+
+/* even though we are not necessarily operating on bs, we need it to
+ * determine if block ops are currently prohibited on the chain */
+if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_CHANGE, errp)) {
+return;
+}
+
+/* final sanity check */
+if (!bdrv_chain_contains(bs, image_bs)) {
+error_setg(errp, '%s' and image file are not in the same chain,
+   device);
+return;
+}
+
+/* if not r/w, reopen to make r/w */
+open_flags = image_bs-open_flags;
+ro = bdrv_is_read_only(image_bs);
+
+if (ro) {
+bdrv_reopen(image_bs, open_flags | BDRV_O_RDWR, local_err);
+if (local_err) {
+error_propagate(errp, local_err);
+return;
+}
+}
+
+ret = bdrv_change_backing_file(image_bs, backing_file,
+   image_bs-drv ? image_bs-drv-format_name : 
);
+
+if (ret  0) {
+error_setg_errno(errp, -ret, Could not change backing file to '%s',
+ backing_file);
+/* don't exit here, so we can try to restore open flags if
+ * appropriate */
+}
+
+if (ro) {
+bdrv_reopen(image_bs, open_flags, local_err);
+if (local_err) {
+error_propagate(errp, local_err); /* will preserve prior errp */
+}
+}
+}
+
 void qmp_blockdev_add(BlockdevOptions *options, Error **errp)
 {
 QmpOutputVisitor *ov = qmp_output_visitor_new();
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 6a697f1..aa12527 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -680,6 +680,32 @@
   'data': 'BlockdevSnapshot' }
 
 ##
+# @change-backing-file
+#
+# Change the backing file in the image file metadata.  This does not
+# cause QEMU to reopen the image file to reparse the backing filename
+# (it may, however, perform a reopen to change permissions from
+# r/o - r/w - r/o, if needed). The new backing file string is written
+# into the image file metadata, and the QEMU internal strings are
+# updated.
+#
+# @image-node-name: The name of the block driver state node of the
+#   image to modify.
+#
+# @device:  The name of the device that owns image-node-name.
+#
+# @backing-file:The string to write as the backing file.  This
+#   string is not validated, so care should be taken
+#   when specifying the string or the image chain may
+#   not be able to be 

[Qemu-devel] [PULL for-2.1 20/24] qapi: Change back sector-count to sectors-count in quorum QAPI events.

2014-07-01 Thread Stefan Hajnoczi
From: Benoît Canet benoit.ca...@irqsave.net

fe069d9d had aligned code and documentation while dropping the s from the
actual JSON output. Fix that.

This also fix test/qemu-iotest/081 since the missing s was causing a 
permutation.

Signed-off-by: Benoit Canet ben...@irqsave.net
Reviewed-by: Eric Blake ebl...@redhat.com
Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
---
 docs/qmp/qmp-events.txt | 26 +-
 qapi/event.json |  8 
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/docs/qmp/qmp-events.txt b/docs/qmp/qmp-events.txt
index 44be891..4a6c2a2 100644
--- a/docs/qmp/qmp-events.txt
+++ b/docs/qmp/qmp-events.txt
@@ -250,14 +250,14 @@ Emitted by the Quorum block driver if it fails to 
establish a quorum.
 
 Data:
 
-- reference:device name if defined else node name.
-- sector-num:   Number of the first sector of the failed read operation.
-- sector-count: Failed read operation sector count.
+- reference: device name if defined else node name.
+- sector-num:Number of the first sector of the failed read operation.
+- sectors-count: Failed read operation sector count.
 
 Example:
 
 { event: QUORUM_FAILURE,
- data: { reference: usr1, sector-num: 345435, sector-count: 5 },
+ data: { reference: usr1, sector-num: 345435, sectors-count: 5 },
  timestamp: { seconds: 1344522075, microseconds: 745528 } }
 
 QUORUM_REPORT_BAD
@@ -267,19 +267,19 @@ Emitted to report a corruption of a Quorum file.
 
 Data:
 
-- error:Error message (json-string, optional)
-  Only present on failure.  This field contains a 
human-readable
-  error message.  There are no semantics other than that the
-  block layer reported an error and clients should not try to
-  interpret the error string.
-- node-name:The graph node name of the block driver state.
-- sector-num:   Number of the first sector of the failed read operation.
-- sector-count: Failed read operation sector count.
+- error: Error message (json-string, optional)
+   Only present on failure.  This field contains a 
human-readable
+   error message.  There are no semantics other than that the
+   block layer reported an error and clients should not try to
+   interpret the error string.
+- node-name: The graph node name of the block driver state.
+- sector-num:Number of the first sector of the failed read operation.
+- sectors-count: Failed read operation sector count.
 
 Example:
 
 { event: QUORUM_REPORT_BAD,
- data: { node-name: 1.raw, sector-num: 345435, sector-count: 5 },
+ data: { node-name: 1.raw, sector-num: 345435, sectors-count: 5 
},
  timestamp: { seconds: 1344522075, microseconds: 745528 } }
 
 RESET
diff --git a/qapi/event.json b/qapi/event.json
index ff97aeb..c51dc49 100644
--- a/qapi/event.json
+++ b/qapi/event.json
@@ -288,12 +288,12 @@
 #
 # @sector-num: number of the first sector of the failed read operation
 #
-# @sector-count: failed read operation sector count
+# @sectors-count: failed read operation sector count
 #
 # Since: 2.0
 ##
 { 'event': 'QUORUM_FAILURE',
-  'data': { 'reference': 'str', 'sector-num': 'int', 'sector-count': 'int' } }
+  'data': { 'reference': 'str', 'sector-num': 'int', 'sectors-count': 'int' } }
 
 ##
 # @QUORUM_REPORT_BAD
@@ -309,13 +309,13 @@
 #
 # @sector-num: number of the first sector of the failed read operation
 #
-# @sector-count: failed read operation sector count
+# @sectors-count: failed read operation sector count
 #
 # Since: 2.0
 ##
 { 'event': 'QUORUM_REPORT_BAD',
   'data': { '*error': 'str', 'node-name': 'str',
-'sector-num': 'int', 'sector-count': 'int' } }
+'sector-num': 'int', 'sectors-count': 'int' } }
 
 ##
 # @VSERPORT_CHANGE
-- 
1.9.3




Re: [Qemu-devel] [RFC] qemu VGA endian swap low level drawing changes

2014-07-01 Thread Alexander Graf


On 01.07.14 10:20, Gerd Hoffmann wrote:

On Mo, 2014-06-30 at 22:32 +1000, Benjamin Herrenschmidt wrote:

On Mon, 2014-06-30 at 13:14 +0200, Gerd Hoffmann wrote:

   Hi,


 From what I can tell, we only ever call the cursor drawing callback on
non-shared surfaces. Should I deduce that the HW cursor emulation simply
doesn't work when using shared surfaces ? Or is there another path I
have missed to handle it ?

Hmm.  Looks like hw-cursor-on-shared-surface broken indeed.  Need to dig
out a guest which actually uses it  go figure when testing your patch
series ...

I don't think I broke it much more than it already was but then I
couldn't find a guest using it. I've tried the plain cirrus DDX in X and
it didn't have any problem... maybe windows ?

Nope.  windows xp doesn't use it.  Anything newer doesn't ship with
cirrus drivers any more (and uses vesa bios support).

Looking at the code the cirrus hardware cursor supports two colors only
(and some funky xor mode).  Guess it simply doesn't cut it as you can't
have your cursors drop shadows with that, so guests are ignoring it.


Windows NT 4 might use it. I remember that I had issues running NT4 with 
Cirrus emulation a while back.





Right. A quick fix would be to add a flag to force always using a shadow
surface and set it in cirrus ... I'm not sure anybody will notice the
performance difference.

I suspect we can rip out hw cursor emulation and nobody will notice the
difference either ...


Very likely ;). Though I think we're better off keeping it around to 
make sure we're still compatible with ancient guests (Windows 3.1 might 
use it too). Making it slow however shouldn't make any difference at all.



Alex




[Qemu-devel] [PULL for-2.1 16/24] iotests: Add more tests to quick group

2014-07-01 Thread Stefan Hajnoczi
From: Max Reitz mre...@redhat.com

While at it, add some more tests to the quick group (those that run with
-nocache in under three seconds on my HDD).

Signed-off-by: Max Reitz mre...@redhat.com
Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
---
 tests/qemu-iotests/group | 38 +++---
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
index 7a2bfca..6e67f61 100644
--- a/tests/qemu-iotests/group
+++ b/tests/qemu-iotests/group
@@ -7,16 +7,16 @@
 #
 # test-group association ... one line per test
 #
-001 rw auto
+001 rw auto quick
 002 rw auto quick
 003 rw auto
 004 rw auto quick
-005 img auto
+005 img auto quick
 006 img auto
 007 snapshot auto
-008 rw auto
-009 rw auto
-010 rw auto
+008 rw auto quick
+009 rw auto quick
+010 rw auto quick
 011 rw auto quick
 012 auto quick
 013 rw auto
@@ -24,36 +24,36 @@
 015 rw snapshot auto
 016 rw auto quick
 017 rw backing auto quick
-018 rw backing auto
+018 rw backing auto quick
 019 rw backing auto quick
 020 rw backing auto quick
-021 io auto
+021 io auto quick
 022 rw snapshot auto
 023 rw auto
 024 rw backing auto quick
 025 rw auto quick
 026 rw blkdbg auto
 027 rw auto quick
-028 rw backing auto
+028 rw backing auto quick
 029 rw auto quick
 030 rw auto backing
 031 rw auto quick
-032 rw auto
+032 rw auto quick
 033 rw auto quick
-034 rw auto backing
+034 rw auto backing quick
 035 rw auto quick
 036 rw auto quick
-037 rw auto backing
-038 rw auto backing
-039 rw auto
+037 rw auto backing quick
+038 rw auto backing quick
+039 rw auto quick
 040 rw auto
 041 rw auto backing
 042 rw auto quick
 043 rw auto backing
 044 rw auto
 045 rw auto quick
-046 rw auto aio
-047 rw auto
+046 rw auto aio quick
+047 rw auto quick
 048 img auto quick
 049 rw auto
 050 rw auto backing quick
@@ -81,20 +81,20 @@
 072 rw auto quick
 073 rw auto quick
 074 rw auto quick
-075 rw auto
+075 rw auto quick
 076 auto
 077 rw auto quick
-078 rw auto
+078 rw auto quick
 079 rw auto
 080 rw auto
 081 rw auto quick
 082 rw auto quick
 083 rw auto
-084 img auto
+084 img auto quick
 085 rw auto
 086 rw auto quick
 087 rw auto quick
-088 rw auto
+088 rw auto quick
 089 rw auto quick
 090 rw auto quick
 091 rw auto quick
-- 
1.9.3




Re: [Qemu-devel] [RFC PATCH V3 1/6] icount: Add QemuOpts for icount

2014-07-01 Thread Frederic Konrad

On 30/06/2014 15:59, Sebastian Tanase wrote:

Make icount parameter use QemuOpts style options in order
to easily add other suboptions.

Signed-off-by: Sebastian Tanase sebastian.tan...@openwide.fr
Tested-by: Camille Bégué camille.be...@openwide.fr
---
  cpus.c| 10 +-
  include/qemu-common.h |  3 ++-
  qemu-options.hx   |  4 ++--
  qtest.c   | 13 +++--
  vl.c  | 35 ---
  5 files changed, 52 insertions(+), 13 deletions(-)

diff --git a/cpus.c b/cpus.c
index 5e7f2cf..dcca96a 100644
--- a/cpus.c
+++ b/cpus.c
@@ -440,13 +440,21 @@ static const VMStateDescription vmstate_timers = {
  }
  };
  
-void configure_icount(const char *option)

+void configure_icount(QemuOpts *opts, Error **errp)
  {
+const char *option;
+
  seqlock_init(timers_state.vm_clock_seqlock, NULL);
  vmstate_register(NULL, 0, vmstate_timers, timers_state);
+option = qemu_opt_get(opts, shift);
  if (!option) {
  return;
  }
+/* When using -icount shift, the shift option will be
+   misinterpreted as a boolean */
+if (strcmp(option, on) == 0 || strcmp(option, off) == 0) {
+error_setg(errp, The shift option must be a number or auto);
+}
  
  icount_warp_timer = timer_new_ns(QEMU_CLOCK_REALTIME,

icount_warp_rt, NULL);
diff --git a/include/qemu-common.h b/include/qemu-common.h
index ae76197..cc346ec 100644
--- a/include/qemu-common.h
+++ b/include/qemu-common.h
@@ -41,6 +41,7 @@
  #include assert.h
  #include signal.h
  #include glib-compat.h
+#include qemu/option.h
  
  #ifdef _WIN32

  #include sysemu/os-win32.h
@@ -105,7 +106,7 @@ static inline char *realpath(const char *path, char 
*resolved_path)
  #endif
  
  /* icount */

-void configure_icount(const char *option);
+void configure_icount(QemuOpts *opts, Error **errp);
  extern int use_icount;
  
  #include qemu/osdep.h

diff --git a/qemu-options.hx b/qemu-options.hx
index 9e54686..143def4 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -3011,11 +3011,11 @@ re-inject them.
  ETEXI
  
  DEF(icount, HAS_ARG, QEMU_OPTION_icount, \

--icount [N|auto]\n \
+-icount [shift=N|auto]\n \
  enable virtual instruction counter with 2^N clock ticks 
per\n \
  instruction\n, QEMU_ARCH_ALL)
  STEXI
-@item -icount [@var{N}|auto]
+@item -icount [shift=@var{N}|auto]
  @findex -icount
  Enable virtual instruction counter.  The virtual cpu will execute one
  instruction every 2^@var{N} ns of virtual time.  If @code{auto} is specified
diff --git a/qtest.c b/qtest.c
index 04a6dc1..ef0d991 100644
--- a/qtest.c
+++ b/qtest.c
@@ -19,6 +19,9 @@
  #include hw/irq.h
  #include sysemu/sysemu.h
  #include sysemu/cpus.h
+#include qemu/config-file.h
+#include qemu/option.h
+#include qemu/error-report.h
  
  #define MAX_IRQ 256
  
@@ -509,10 +512,16 @@ static void qtest_event(void *opaque, int event)

  }
  }
  
-int qtest_init_accel(MachineClass *mc)

+static void configure_qtest_icount(const char *options)
  {
-configure_icount(0);
+QemuOpts *opts  = qemu_opts_parse(qemu_find_opts(icount), options, 1);
+configure_icount(opts, error_abort);
+qemu_opts_del(opts);
+}
  
+int qtest_init_accel(MachineClass *mc)

+{
+configure_qtest_icount(0);
  return 0;
  }
  
diff --git a/vl.c b/vl.c

index 41ddcd2..103027f 100644
--- a/vl.c
+++ b/vl.c
@@ -537,6 +537,20 @@ static QemuOptsList qemu_mem_opts = {
  },
  };
  
+static QemuOptsList qemu_icount_opts = {

+.name = icount,
+.implied_opt_name = shift,
+.merge_lists = true,
+.head = QTAILQ_HEAD_INITIALIZER(qemu_icount_opts.head),
+.desc = {
+{
+.name = shift,
+.type = QEMU_OPT_STRING,
+},
+{ /* end of list */ }
+},
+};
+
  /**
   * Get machine options
   *
@@ -2896,13 +2910,12 @@ int main(int argc, char **argv, char **envp)
  {
  int i;
  int snapshot, linux_boot;
-const char *icount_option = NULL;
  const char *initrd_filename;
  const char *kernel_filename, *kernel_cmdline;
  const char *boot_order;
  DisplayState *ds;
  int cyls, heads, secs, translation;
-QemuOpts *hda_opts = NULL, *opts, *machine_opts;
+QemuOpts *hda_opts = NULL, *opts, *machine_opts, *icount_opts = NULL;
  QemuOptsList *olist;
  int optind;
  const char *optarg;
@@ -2967,6 +2980,7 @@ int main(int argc, char **argv, char **envp)
  qemu_add_opts(qemu_msg_opts);
  qemu_add_opts(qemu_name_opts);
  qemu_add_opts(qemu_numa_opts);
+qemu_add_opts(qemu_icount_opts);
  
  runstate_init();
  
@@ -3817,7 +3831,11 @@ int main(int argc, char **argv, char **envp)

  }
  break;
  case QEMU_OPTION_icount:
-icount_option = optarg;
+icount_opts = qemu_opts_parse(qemu_find_opts(icount),
+   

[Qemu-devel] [PULL for-2.1 23/24] block: extend block-commit to accept a string for the backing file

2014-07-01 Thread Stefan Hajnoczi
From: Jeff Cody jc...@redhat.com

On some image chains, QEMU may not always be able to resolve the
filenames properly, when updating the backing file of an image
after a block commit.

For instance, certain relative pathnames may fail, or drives may
have been specified originally by file descriptor (e.g. /dev/fd/???),
or a relative protocol pathname may have been used.

In these instances, QEMU may lack the information to be able to make
the correct choice, but the user or management layer most likely does
have that knowledge.

With this extension to the block-commit api, the user is able to change
the backing file of the overlay image as part of the block-commit
operation.

This allows the change to be 'safe', in the sense that if the attempt
to write the overlay image metadata fails, then the block-commit
operation returns failure, without disrupting the guest.

If the commit top is the active layer, then specifying the backing
file string will be treated as an error (there is no overlay image
to modify in that case).

If a backing file string is not specified in the command, the backing
file string to use is determined in the same manner as it was
previously.

Reviewed-by: Eric Blake ebl...@redhat.com
Signed-off-by: Jeff Cody jc...@redhat.com
Reviewed-by: Kevin Wolf kw...@redhat.com
Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
---
 block.c   |  8 ++--
 block/commit.c|  9 ++---
 blockdev.c|  8 +++-
 include/block/block.h |  3 ++-
 include/block/block_int.h |  3 ++-
 qapi/block-core.json  | 20 ++--
 qmp-commands.hx   | 19 ++-
 7 files changed, 59 insertions(+), 11 deletions(-)

diff --git a/block.c b/block.c
index f45e63c..f80e2b2 100644
--- a/block.c
+++ b/block.c
@@ -2555,12 +2555,15 @@ typedef struct BlkIntermediateStates {
  *
  * base - active
  *
+ * If backing_file_str is non-NULL, it will be used when modifying top's
+ * overlay image metadata.
+ *
  * Error conditions:
  *  if active == top, that is considered an error
  *
  */
 int bdrv_drop_intermediate(BlockDriverState *active, BlockDriverState *top,
-   BlockDriverState *base)
+   BlockDriverState *base, const char 
*backing_file_str)
 {
 BlockDriverState *intermediate;
 BlockDriverState *base_bs = NULL;
@@ -2612,7 +2615,8 @@ int bdrv_drop_intermediate(BlockDriverState *active, 
BlockDriverState *top,
 }
 
 /* success - we can delete the intermediate states, and link top-base */
-ret = bdrv_change_backing_file(new_top_bs, base_bs-filename,
+backing_file_str = backing_file_str ? backing_file_str : base_bs-filename;
+ret = bdrv_change_backing_file(new_top_bs, backing_file_str,
base_bs-drv ? base_bs-drv-format_name : 
);
 if (ret) {
 goto exit;
diff --git a/block/commit.c b/block/commit.c
index 5c09f44..91517d3 100644
--- a/block/commit.c
+++ b/block/commit.c
@@ -37,6 +37,7 @@ typedef struct CommitBlockJob {
 BlockdevOnError on_error;
 int base_flags;
 int orig_overlay_flags;
+char *backing_file_str;
 } CommitBlockJob;
 
 static int coroutine_fn commit_populate(BlockDriverState *bs,
@@ -141,7 +142,7 @@ wait:
 
 if (!block_job_is_cancelled(s-common)  sector_num == end) {
 /* success */
-ret = bdrv_drop_intermediate(active, top, base);
+ret = bdrv_drop_intermediate(active, top, base, s-backing_file_str);
 }
 
 exit_free_buf:
@@ -158,7 +159,7 @@ exit_restore_reopen:
 if (overlay_bs  s-orig_overlay_flags != bdrv_get_flags(overlay_bs)) {
 bdrv_reopen(overlay_bs, s-orig_overlay_flags, NULL);
 }
-
+g_free(s-backing_file_str);
 block_job_completed(s-common, ret);
 }
 
@@ -182,7 +183,7 @@ static const BlockJobDriver commit_job_driver = {
 void commit_start(BlockDriverState *bs, BlockDriverState *base,
   BlockDriverState *top, int64_t speed,
   BlockdevOnError on_error, BlockDriverCompletionFunc *cb,
-  void *opaque, Error **errp)
+  void *opaque, const char *backing_file_str, Error **errp)
 {
 CommitBlockJob *s;
 BlockReopenQueue *reopen_queue = NULL;
@@ -244,6 +245,8 @@ void commit_start(BlockDriverState *bs, BlockDriverState 
*base,
 s-base_flags  = orig_base_flags;
 s-orig_overlay_flags  = orig_overlay_flags;
 
+s-backing_file_str = g_strdup(backing_file_str);
+
 s-on_error = on_error;
 s-common.co = qemu_coroutine_create(commit_run);
 
diff --git a/blockdev.c b/blockdev.c
index 57373d3..48315e8 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1915,6 +1915,7 @@ void qmp_block_stream(const char *device, bool has_base,
 void qmp_block_commit(const char *device,
   bool has_base, const char *base,
   bool has_top, const char *top,
+  bool has_backing_file, const char *backing_file,
  

Re: [Qemu-devel] [PATCH 0/3] virtio-blk: Suppress error action on r/w beyond end

2014-07-01 Thread Markus Armbruster
Please consider for 2.1.  It needs git-am -3 by now; if you need a
respin, let me know.

Markus Armbruster arm...@redhat.com writes:

 When a device model's I/O operation fails, we execute the error
 action.  This lets layers above QEMU implement thin provisioning, or
 attempt to correct errors before they reach the guest.  But when the
 I/O operation fails because its invalid, reporting the error to the
 guest is the only sensible action.

 This short series does exactly that for virtio-blk.  I intend to do
 the same for IDE and SCSI.

 Markus Armbruster (3):
   virtio-blk: Factor common checks out of virtio_blk_handle_read/write()
   virtio-blk: Bypass error action and I/O accounting on invalid r/w
   virtio-blk: Treat read/write beyond end as invalid

  hw/block/virtio-blk.c | 45 +
  1 file changed, 29 insertions(+), 16 deletions(-)



[Qemu-devel] [PULL for-2.1 24/24] block: add backing-file option to block-stream

2014-07-01 Thread Stefan Hajnoczi
From: Jeff Cody jc...@redhat.com

On some image chains, QEMU may not always be able to resolve the
filenames properly, when updating the backing file of an image
after a block job.

For instance, certain relative pathnames may fail, or drives may
have been specified originally by file descriptor (e.g. /dev/fd/???),
or a relative protocol pathname may have been used.

In these instances, QEMU may lack the information to be able to make
the correct choice, but the user or management layer most likely does
have that knowledge.

With this extension to the block-stream api, the user is able to change
the backing file of the active layer as part of the block-stream
operation.

This allows the change to be 'safe', in the sense that if the attempt
to write the active image metadata fails, then the block-stream
operation returns failure, without disrupting the guest.

If a backing file string is not specified in the command, the backing
file string to use is determined in the same manner as it was
previously.

Reviewed-by: Eric Blake ebl...@redhat.com
Signed-off-by: Jeff Cody jc...@redhat.com
Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
---
 block/stream.c   | 11 +--
 blockdev.c   | 23 +++
 hmp.c|  2 +-
 qapi/block-core.json | 19 +--
 qmp-commands.hx  |  2 +-
 5 files changed, 43 insertions(+), 14 deletions(-)

diff --git a/block/stream.c b/block/stream.c
index 0433409..34de8ba 100644
--- a/block/stream.c
+++ b/block/stream.c
@@ -32,7 +32,7 @@ typedef struct StreamBlockJob {
 RateLimit limit;
 BlockDriverState *base;
 BlockdevOnError on_error;
-char backing_file_id[1024];
+char *backing_file_str;
 } StreamBlockJob;
 
 static int coroutine_fn stream_populate(BlockDriverState *bs,
@@ -186,7 +186,7 @@ wait:
 if (!block_job_is_cancelled(s-common)  sector_num == end  ret == 0) {
 const char *base_id = NULL, *base_fmt = NULL;
 if (base) {
-base_id = s-backing_file_id;
+base_id = s-backing_file_str;
 if (base-drv) {
 base_fmt = base-drv-format_name;
 }
@@ -196,6 +196,7 @@ wait:
 }
 
 qemu_vfree(buf);
+g_free(s-backing_file_str);
 block_job_completed(s-common, ret);
 }
 
@@ -217,7 +218,7 @@ static const BlockJobDriver stream_job_driver = {
 };
 
 void stream_start(BlockDriverState *bs, BlockDriverState *base,
-  const char *base_id, int64_t speed,
+  const char *backing_file_str, int64_t speed,
   BlockdevOnError on_error,
   BlockDriverCompletionFunc *cb,
   void *opaque, Error **errp)
@@ -237,9 +238,7 @@ void stream_start(BlockDriverState *bs, BlockDriverState 
*base,
 }
 
 s-base = base;
-if (base_id) {
-pstrcpy(s-backing_file_id, sizeof(s-backing_file_id), base_id);
-}
+s-backing_file_str = g_strdup(backing_file_str);
 
 s-on_error = on_error;
 s-common.co = qemu_coroutine_create(stream_run);
diff --git a/blockdev.c b/blockdev.c
index 48315e8..48bd9a3 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1871,14 +1871,17 @@ static void block_job_cb(void *opaque, int ret)
 bdrv_put_ref_bh_schedule(bs);
 }
 
-void qmp_block_stream(const char *device, bool has_base,
-  const char *base, bool has_speed, int64_t speed,
+void qmp_block_stream(const char *device,
+  bool has_base, const char *base,
+  bool has_backing_file, const char *backing_file,
+  bool has_speed, int64_t speed,
   bool has_on_error, BlockdevOnError on_error,
   Error **errp)
 {
 BlockDriverState *bs;
 BlockDriverState *base_bs = NULL;
 Error *local_err = NULL;
+const char *base_name = NULL;
 
 if (!has_on_error) {
 on_error = BLOCKDEV_ON_ERROR_REPORT;
@@ -1894,15 +1897,27 @@ void qmp_block_stream(const char *device, bool has_base,
 return;
 }
 
-if (base) {
+if (has_base) {
 base_bs = bdrv_find_backing_image(bs, base);
 if (base_bs == NULL) {
 error_set(errp, QERR_BASE_NOT_FOUND, base);
 return;
 }
+base_name = base;
 }
 
-stream_start(bs, base_bs, base, has_speed ? speed : 0,
+/* if we are streaming the entire chain, the result will have no backing
+ * file, and specifying one is therefore an error */
+if (base_bs == NULL  has_backing_file) {
+error_setg(errp, backing file specified, but streaming the 
+ entire chain);
+return;
+}
+
+/* backing_file string overrides base bs filename */
+base_name = has_backing_file ? backing_file : base_name;
+
+stream_start(bs, base_bs, base_name, has_speed ? speed : 0,
  on_error, block_job_cb, bs, local_err);
 if (local_err) {
 error_propagate(errp, local_err);
diff --git a/hmp.c b/hmp.c

[Qemu-devel] [PULL for-2.1 0/1] Tracing pull request

2014-07-01 Thread Stefan Hajnoczi
The following changes since commit 53a259da5697ec8a82463161e2e32ff942a08bc2:

  Merge remote-tracking branch 
'remotes/awilliam/tags/vfio-pci-for-qemu-20140630.0' into staging (2014-06-30 
18:31:07 +0100)

are available in the git repository at:


  git://github.com/stefanha/qemu.git tags/tracing-pull-request

for you to fetch changes up to bc78cff9757782501db15d39828e6af4186fe331:

  trace: add qemu_system_powerdown_request and qemu_system_shutdown_request 
trace events (2014-07-01 10:56:13 +0200)


Tracing pull request


Yang Zhiyong (1):
  trace: add qemu_system_powerdown_request and qemu_system_shutdown_request 
trace events

 trace-events | 2 ++
 vl.c | 2 ++
 2 files changed, 4 insertions(+)

-- 
1.9.3




  1   2   3   4   >