[libvirt] [PATCH] qemu: enable multifunction for older qemu
by Eric Blake
Now that RHEL 6.2 Beta is out, it would be nice to test multifunction
devices on that platform. This changes things so that the multifunction
cap bit can be set in two different ways: by version comparison (needed
for qemu 0.13 which lacked a -device query), and by -device query
(provided by qemu.git and backported to the RHEL beta build of
qemu-kvm which still claims to be a modified 0.12, and therefore needed
for RHEL).
* src/qemu/qemu_capabilities.c (qemuCapsParseDeviceStr): Allow
second method of setting multifunction cap bit.
* tests/qemuhelptest.c (mymain): Test it.
* tests/qemuhelpdata/qemu-kvm-0.12.1.2-rhel62-beta: New file.
* tests/qemuhelpdata/qemu-kvm-0.12.1.2-rhel62-beta-device: Likewise.
---
src/qemu/qemu_capabilities.c | 2 +
tests/qemuhelpdata/qemu-kvm-0.12.1.2-rhel62-beta | 230 ++++++++++++++++++++
.../qemu-kvm-0.12.1.2-rhel62-beta-device | 120 ++++++++++
tests/qemuhelptest.c | 59 +++++
4 files changed, 411 insertions(+), 0 deletions(-)
create mode 100644 tests/qemuhelpdata/qemu-kvm-0.12.1.2-rhel62-beta
create mode 100644 tests/qemuhelpdata/qemu-kvm-0.12.1.2-rhel62-beta-device
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index a653243..49be5a2 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -1264,6 +1264,8 @@ qemuCapsParseDeviceStr(const char *str, virBitmapPtr flags)
/* Features of given devices. */
if (strstr(str, "pci-assign.configfd"))
qemuCapsSet(flags, QEMU_CAPS_PCI_CONFIGFD);
+ if (strstr(str, "pci-assign.multifunction"))
+ qemuCapsSet(flags, QEMU_CAPS_PCI_MULTIFUNCTION);
if (strstr(str, "virtio-blk-pci.bootindex")) {
qemuCapsSet(flags, QEMU_CAPS_BOOTINDEX);
if (strstr(str, "pci-assign.bootindex"))
diff --git a/tests/qemuhelpdata/qemu-kvm-0.12.1.2-rhel62-beta b/tests/qemuhelpdata/qemu-kvm-0.12.1.2-rhel62-beta
new file mode 100644
index 0000000..d5927e6
--- /dev/null
+++ b/tests/qemuhelpdata/qemu-kvm-0.12.1.2-rhel62-beta
@@ -0,0 +1,230 @@
+QEMU PC emulator version 0.12.1 (qemu-kvm-0.12.1.2), Copyright (c) 2003-2008 Fabrice Bellard
+
+WARNING: Direct use of qemu-kvm from the command line is not recommended by Red Hat.
+WARNING: Some command line options listed here may not be available in future releases.
+WARNING: Red Hat recommends the use of libvirt as the stable management interface.
+
+usage: qemu [options] [disk_image]
+
+'disk_image' is a raw hard image image for IDE hard disk 0
+
+Standard options:
+-h or -help display this help and exit
+-version display version information and exit
+-M machine select emulated machine (-M ? for list)
+-cpu cpu select CPU (-cpu ? for list)
+-smp n[,maxcpus=cpus][,cores=cores][,threads=threads][,sockets=sockets]
+ set the number of CPUs to 'n' [default=1]
+ maxcpus= maximum number of total cpus, including
+ offline CPUs for hotplug etc.
+ cores= number of CPU cores on one socket
+ threads= number of threads on one CPU core
+ sockets= number of discrete sockets in the system
+-numa node[,mem=size][,cpus=cpu[-cpu]][,nodeid=node]
+-fda/-fdb file use 'file' as floppy disk 0/1 image
+-hda/-hdb file use 'file' as IDE hard disk 0/1 image
+-hdc/-hdd file use 'file' as IDE hard disk 2/3 image
+-cdrom file use 'file' as IDE cdrom image (cdrom is ide1 master)
+-drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,index=i]
+ [,cyls=c,heads=h,secs=s[,trans=t]][,snapshot=on|off]
+ [,cache=writethrough|writeback|none|unsafe][,format=f]
+ [,serial=s][,addr=A][,id=name][,aio=threads|native]
+ [,readonly=on|off][,copy-on-read=on|off][,stream=on|off]
+ use 'file' as a drive image
+-set group.id.arg=value
+ set <arg> parameter for item <id> of type <group>
+ i.e. -set drive.$id.file=/path/to/image
+-global driver.property=value
+ set a global default for a driver property
+-mtdblock file use 'file' as on-board Flash memory image
+-sd file use 'file' as SecureDigital card image
+-pflash file use 'file' as a parallel flash image
+-boot [order=drives][,once=drives][,menu=on|off]
+ 'drives': floppy (a), hard disk (c), CD-ROM (d), network (n)
+-snapshot write to temporary files instead of disk image files
+-m megs set virtual RAM size to megs MB [default=128]
+-k language use keyboard layout (for example 'fr' for French)
+-audio-help print list of audio drivers and their options
+-soundhw c1,... enable audio support
+ and only specified sound cards (comma separated list)
+ use -soundhw ? to get the list of supported cards
+ use -soundhw all to enable all of them
+-usb enable the USB driver (will be the default soon)
+-usbdevice name add the host or guest USB device 'name'
+-device driver[,prop[=value][,...]]
+ add device (based on driver)
+ prop=value,... sets driver properties
+ use -device ? to print all possible drivers
+ use -device driver,? to print all possible properties
+-name string1[,process=string2] set the name of the guest
+ string1 sets the window title and string2 the process name (on Linux)
+-uuid %08x-%04x-%04x-%04x-%012x
+ specify machine UUID
+
+Display options:
+-nographic disable graphical output and redirect serial I/Os to console
+-spice <args> enable spice
+-portrait rotate graphical output 90 deg left (only PXA LCD)
+-vga [std|cirrus|vmware|qxl|xenfb|none]
+ select video card type
+-full-screen start in full screen
+-vnc display start a VNC server on display
+
+i386 target only:
+-win2k-hack use it when installing Windows 2000 to avoid a disk full bug
+-no-fd-bootchk disable boot signature checking for floppy disks
+-no-acpi disable ACPI
+-balloon none disable balloon device
+-balloon virtio[,addr=str]
+ enable virtio balloon device (default)
+-acpitable [sig=str][,rev=n][,oem_id=str][,oem_table_id=str][,oem_rev=n][,asl_compiler_id=str][,asl_compiler_rev=n][,data=file1[:file2]...]
+ ACPI table description
+-smbios file=binary
+ Load SMBIOS entry from binary file
+-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]
+ Specify SMBIOS type 0 fields
+-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]
+ [,uuid=uuid][,sku=str][,family=str]
+ Specify SMBIOS type 1 fields
+
+Network options:
+-net nic[,vlan=n][,macaddr=mac][,model=type][,name=str][,addr=str][,vectors=v]
+ create a new Network Interface Card and connect it to VLAN 'n'
+-net user[,vlan=n][,name=str][,net=addr[/mask]][,host=addr][,restrict=y|n]
+ [,hostname=host][,dhcpstart=addr][,dns=addr][,tftp=dir][,bootfile=f]
+ [,hostfwd=rule][,guestfwd=rule][,smb=dir[,smbserver=addr]]
+ connect the user mode network stack to VLAN 'n', configure its
+ DHCP server and enabled optional services
+-net tap[,vlan=n][,name=str][,fd=h][,ifname=name][,script=file][,downscript=dfile][,sndbuf=nbytes][,vnet_hdr=on|off][,vhost=on|off][,vhostfd=h][,vhostforce=on|off]
+ connect the host TAP network interface to VLAN 'n' and use the
+ network scripts 'file' (default=/etc/qemu-ifup)
+ and 'dfile' (default=/etc/qemu-ifdown);
+ use '[down]script=no' to disable script execution;
+ use 'fd=h' to connect to an already opened TAP interface
+ use 'sndbuf=nbytes' to limit the size of the send buffer (the
+ default is disabled 'sndbuf=0' to enable flow control set 'sndbuf=1048576')
+ use vnet_hdr=off to avoid enabling the IFF_VNET_HDR tap flag; use
+ vnet_hdr=on to make the lack of IFF_VNET_HDR support an error condition
+ use vhost=on to enable experimental in kernel accelerator
+ (only has effect for virtio guests which use MSIX)
+ use vhostforce=on to force vhost on for non-MSIX virtio guests
+ use 'vhostfd=h' to connect to an already opened vhost net device
+-net socket[,vlan=n][,name=str][,fd=h][,listen=[host]:port][,connect=host:port]
+ connect the vlan 'n' to another VLAN using a socket connection
+-net socket[,vlan=n][,name=str][,fd=h][,mcast=maddr:port]
+ connect the vlan 'n' to multicast maddr and port
+-net dump[,vlan=n][,file=f][,len=n]
+ dump traffic on vlan 'n' to file 'f' (max n bytes per packet)
+-net none use it alone to have zero network devices; if no -net option
+ is provided, the default is '-net nic -net user'
+-netdev [user|tap|socket],id=str[,option][,option][,...]
+
+Character device options:
+-chardev null,id=id
+-chardev socket,id=id[,host=host],port=host[,to=to][,ipv4][,ipv6][,nodelay]
+ [,server][,nowait][,telnet] (tcp)
+-chardev socket,id=id,path=path[,server][,nowait][,telnet] (unix)
+-chardev udp,id=id[,host=host],port=port[,localaddr=localaddr]
+ [,localport=localport][,ipv4][,ipv6]
+-chardev msmouse,id=id
+-chardev vc,id=id[[,width=width][,height=height]][[,cols=cols][,rows=rows]]
+-chardev file,id=id,path=path
+-chardev pipe,id=id,path=path
+-chardev pty,id=id
+-chardev stdio,id=id
+-chardev tty,id=id,path=path
+-chardev parport,id=id,path=path
+-chardev spicevmc,id=id,debug=debug,name=name
+
+Bluetooth(R) options:
+-bt hci,null dumb bluetooth HCI - doesn't respond to commands
+-bt hci,host[:id]
+ use host's HCI with the given name
+-bt hci[,vlan=n]
+ emulate a standard HCI in virtual scatternet 'n'
+-bt vhci[,vlan=n]
+ add host computer to virtual scatternet 'n' using VHCI
+-bt device:dev[,vlan=n]
+ emulate a bluetooth device 'dev' in scatternet 'n'
+
+Linux/Multiboot boot specific:
+-kernel bzImage use 'bzImage' as kernel image
+-append cmdline use 'cmdline' as kernel command line
+-initrd file use 'file' as initial ram disk
+
+Debug/Expert options:
+-serial dev redirect the serial port to char device 'dev'
+-parallel dev redirect the parallel port to char device 'dev'
+-monitor dev redirect the monitor to char device 'dev'
+-qmp dev like -monitor but opens in 'control' mode.
+-mon chardev=[name][,mode=readline|control][,default]
+-pidfile file write PID to 'file'
+-singlestep always run in singlestep mode
+-S freeze CPU at startup (use 'c' to start execution)
+-gdb dev wait for gdb connection on 'dev'
+-s shorthand for -gdb tcp::1234
+-d item1,... output log to /tmp/qemu.log (use -d ? for a list of log items)
+-hdachs c,h,s[,t]
+ force hard disk 0 physical geometry and the optional BIOS
+ translation (t=none or lba) (usually qemu can guess them)
+-L path set the directory for the BIOS, VGA BIOS and keymaps
+-bios file set the filename for the BIOS
+-enable-kvm enable KVM full virtualization support
+-no-reboot exit instead of rebooting
+-no-shutdown stop before shutdown
+-loadvm [tag|id]
+ start right away with a saved state (loadvm in monitor)
+-daemonize daemonize QEMU after initializing
+-option-rom rom load a file, rom, into the option ROM space
+-clock force the use of the given methods for timer alarm.
+ To see what timers are available use -clock ?
+-rtc [base=utc|localtime|date][,clock=host|vm][,driftfix=none|slew]
+ set the RTC base and clock, enable drift fix for clock ticks
+-icount [N|auto]
+ enable virtual instruction counter with 2^N clock ticks per
+ instruction
+-watchdog i6300esb|ib700
+ enable virtual hardware watchdog [default=none]
+-watchdog-action reset|shutdown|poweroff|pause|debug|none
+ action when watchdog fires [default=reset]
+-echr chr set terminal escape character instead of ctrl-a
+-virtioconsole c
+ set virtio console
+-show-cursor show cursor
+-tb-size n set TB size
+-incoming p prepare for incoming migration, listen on port p
+-nodefaults don't create default devices.
+-chroot dir Chroot to dir just before starting the VM.
+-runas user Change to user id user just before starting the VM.
+-nodefconfig
+ do not load default config files at startup
+-readconfig <file>
+-writeconfig <file>
+ read/write config file
+-no-kvm disable KVM hardware virtualization
+-no-kvm-irqchip disable KVM kernel mode PIC/IOAPIC/LAPIC
+-no-kvm-pit disable KVM kernel mode PIT
+-no-kvm-pit-reinjection disable KVM kernel mode PIT interrupt reinjection
+-pcidevice host=bus:dev.func[,dma=none][,name=string]
+ expose a PCI device to the guest OS.
+ dma=none: don't perform any dma translations (default is to use an iommu)
+ 'string' is used in log output.
+-nvram FILE provide ia64 nvram contents
+-tdf enable guest time drift compensation
+-kvm-shadow-memory MEGABYTES
+ allocate MEGABYTES for kvm mmu shadowing
+-mem-path FILE provide backing storage for guest RAM
+-mem-prealloc preallocate guest memory (use with -mempath)
+-redhat-disable-KSM disable KSM on guest physical memory
+
+During emulation, the following keys are useful:
+ctrl-alt-f toggle full screen
+ctrl-alt-n switch to virtual console 'n'
+ctrl-alt toggle mouse and keyboard grab
+
+When using -nographic, press 'ctrl-a h' to get some help.
+
+WARNING: Direct use of qemu-kvm from the command line is not recommended by Red Hat.
+WARNING: Some command line options listed here may not be available in future releases.
+WARNING: Red Hat recommends the use of libvirt as the stable management interface.
+
diff --git a/tests/qemuhelpdata/qemu-kvm-0.12.1.2-rhel62-beta-device b/tests/qemuhelpdata/qemu-kvm-0.12.1.2-rhel62-beta-device
new file mode 100644
index 0000000..ee0fd78
--- /dev/null
+++ b/tests/qemuhelpdata/qemu-kvm-0.12.1.2-rhel62-beta-device
@@ -0,0 +1,120 @@
+name "pci-bridge", bus PCI
+name "virtio-balloon-pci", bus PCI
+name "virtio-serial-pci", bus PCI, alias "virtio-serial"
+name "virtio-net-pci", bus PCI
+name "virtio-blk-pci", bus PCI, alias "virtio-blk"
+name "i82562", bus PCI
+name "i82559er", bus PCI
+name "i82559c", bus PCI
+name "i82559b", bus PCI
+name "i82559a", bus PCI
+name "i82558b", bus PCI
+name "i82558a", bus PCI
+name "i82557c", bus PCI
+name "i82557b", bus PCI
+name "i82557a", bus PCI
+name "i82551", bus PCI
+name "i82550", bus PCI
+name "pcnet", bus PCI
+name "rtl8139", bus PCI
+name "e1000", bus PCI, desc "Intel Gigabit Ethernet"
+name "ide-drive", bus IDE
+name "isa-ide", bus ISA
+name "ES1370", bus PCI, desc "ENSONIQ AudioPCI ES1370"
+name "AC97", bus PCI, desc "Intel 82801AA AC97 Audio"
+name "intel-hda", bus PCI, desc "Intel HD Audio Controller"
+name "hda-duplex", bus HDA, desc "HDA Audio Codec, duplex"
+name "hda-output", bus HDA, desc "HDA Audio Codec, output-only"
+name "VGA", bus PCI
+name "SUNW,fdtwo", bus System
+name "sysbus-fdc", bus System
+name "isa-serial", bus ISA
+name "cirrus-vga", bus PCI, desc "Cirrus CLGD 54xx VGA"
+name "isa-parallel", bus ISA
+name "sga", bus ISA, desc "Serial Graphics Adapter"
+name "ich9-usb-uhci3", bus PCI
+name "ich9-usb-uhci2", bus PCI
+name "ich9-usb-uhci1", bus PCI
+name "piix4-usb-uhci", bus PCI
+name "piix3-usb-uhci", bus PCI
+name "ib700", bus ISA
+name "ne2k_isa", bus ISA
+name "testdev", bus ISA
+name "pci-assign", bus PCI, desc "pass through host pci devices to the guest"
+name "qxl", bus PCI, desc "Spice QXL GPU (secondary)"
+name "qxl-vga", bus PCI, desc "Spice QXL GPU (primary, vga compatible)"
+name "smbus-eeprom", bus I2C
+name "usb-hub", bus USB
+name "usb-host", bus USB
+name "usb-kbd", bus USB
+name "usb-mouse", bus USB
+name "usb-tablet", bus USB
+name "usb-storage", bus USB
+name "scsi-disk", bus SCSI, desc "virtual SCSI disk or CD-ROM (legacy)"
+name "scsi-cd", bus SCSI, desc "virtual SCSI CD-ROM"
+name "scsi-hd", bus SCSI, desc "virtual SCSI disk"
+name "usb-ccid", bus USB, desc "CCID Rev 1.1 smartcard reader"
+name "ccid-card-passthru", bus ccid-bus, desc "passthrough smartcard"
+name "virtserialport", bus virtio-serial-bus
+name "virtconsole", bus virtio-serial-bus
+name "ich9-usb-ehci1", bus PCI
+name "usb-ehci", bus PCI
+name "i6300esb", bus PCI
+name "ne2k_pci", bus PCI
+pci-assign.host=pci-hostaddr
+pci-assign.iommu=uint32
+pci-assign.bootindex=int32
+pci-assign.configfd=string
+pci-assign.addr=pci-devfn
+pci-assign.romfile=string
+pci-assign.rombar=uint32
+pci-assign.multifunction=on/off
+virtio-blk-pci.class=hex32
+virtio-blk-pci.drive=drive
+virtio-blk-pci.logical_block_size=uint16
+virtio-blk-pci.physical_block_size=uint16
+virtio-blk-pci.min_io_size=uint16
+virtio-blk-pci.opt_io_size=uint32
+virtio-blk-pci.bootindex=int32
+virtio-blk-pci.discard_granularity=uint32
+virtio-blk-pci.ioeventfd=on/off
+virtio-blk-pci.vectors=uint32
+virtio-blk-pci.indirect_desc=on/off
+virtio-blk-pci.event_idx=on/off
+virtio-blk-pci.scsi=on/off
+virtio-blk-pci.addr=pci-devfn
+virtio-blk-pci.romfile=string
+virtio-blk-pci.rombar=uint32
+virtio-blk-pci.multifunction=on/off
+virtio-net-pci.ioeventfd=on/off
+virtio-net-pci.vectors=uint32
+virtio-net-pci.indirect_desc=on/off
+virtio-net-pci.event_idx=on/off
+virtio-net-pci.csum=on/off
+virtio-net-pci.guest_csum=on/off
+virtio-net-pci.gso=on/off
+virtio-net-pci.guest_tso4=on/off
+virtio-net-pci.guest_tso6=on/off
+virtio-net-pci.guest_ecn=on/off
+virtio-net-pci.guest_ufo=on/off
+virtio-net-pci.host_tso4=on/off
+virtio-net-pci.host_tso6=on/off
+virtio-net-pci.host_ecn=on/off
+virtio-net-pci.host_ufo=on/off
+virtio-net-pci.mrg_rxbuf=on/off
+virtio-net-pci.status=on/off
+virtio-net-pci.ctrl_vq=on/off
+virtio-net-pci.ctrl_rx=on/off
+virtio-net-pci.ctrl_vlan=on/off
+virtio-net-pci.ctrl_rx_extra=on/off
+virtio-net-pci.mac=macaddr
+virtio-net-pci.vlan=vlan
+virtio-net-pci.netdev=netdev
+virtio-net-pci.bootindex=int32
+virtio-net-pci.x-txtimer=uint32
+virtio-net-pci.x-txburst=int32
+virtio-net-pci.tx=string
+virtio-net-pci.addr=pci-devfn
+virtio-net-pci.romfile=string
+virtio-net-pci.rombar=uint32
+virtio-net-pci.multifunction=on/off
diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c
index 8a06568..fcee41f 100644
--- a/tests/qemuhelptest.c
+++ b/tests/qemuhelptest.c
@@ -507,6 +507,65 @@ mymain(void)
QEMU_CAPS_USB_HUB,
QEMU_CAPS_NO_SHUTDOWN,
QEMU_CAPS_PCI_ROMBAR);
+ DO_TEST("qemu-kvm-0.12.1.2-rhel62-beta", 12001, 1, 0,
+ QEMU_CAPS_VNC_COLON,
+ QEMU_CAPS_NO_REBOOT,
+ QEMU_CAPS_DRIVE,
+ QEMU_CAPS_NAME,
+ QEMU_CAPS_UUID,
+ QEMU_CAPS_VNET_HDR,
+ QEMU_CAPS_MIGRATE_QEMU_TCP,
+ QEMU_CAPS_MIGRATE_QEMU_EXEC,
+ QEMU_CAPS_DRIVE_CACHE_V2,
+ QEMU_CAPS_DRIVE_CACHE_UNSAFE,
+ QEMU_CAPS_KVM,
+ QEMU_CAPS_DRIVE_FORMAT,
+ QEMU_CAPS_DRIVE_SERIAL,
+ QEMU_CAPS_DRIVE_READONLY,
+ QEMU_CAPS_VGA,
+ QEMU_CAPS_0_10,
+ QEMU_CAPS_PCIDEVICE,
+ QEMU_CAPS_MEM_PATH,
+ QEMU_CAPS_MIGRATE_QEMU_UNIX,
+ QEMU_CAPS_CHARDEV,
+ QEMU_CAPS_ENABLE_KVM,
+ QEMU_CAPS_BALLOON,
+ QEMU_CAPS_DEVICE,
+ QEMU_CAPS_SMP_TOPOLOGY,
+ QEMU_CAPS_RTC,
+ QEMU_CAPS_VHOST_NET,
+ QEMU_CAPS_NO_KVM_PIT,
+ QEMU_CAPS_TDF,
+ QEMU_CAPS_PCI_CONFIGFD,
+ QEMU_CAPS_NODEFCONFIG,
+ QEMU_CAPS_BOOT_MENU,
+ QEMU_CAPS_NAME_PROCESS,
+ QEMU_CAPS_SMBIOS_TYPE,
+ QEMU_CAPS_VGA_QXL,
+ QEMU_CAPS_SPICE,
+ QEMU_CAPS_VGA_NONE,
+ QEMU_CAPS_MIGRATE_QEMU_FD,
+ QEMU_CAPS_BOOTINDEX,
+ QEMU_CAPS_HDA_DUPLEX,
+ QEMU_CAPS_DRIVE_AIO,
+ QEMU_CAPS_PCI_BOOTINDEX,
+ QEMU_CAPS_CCID_PASSTHRU,
+ QEMU_CAPS_CHARDEV_SPICEVMC,
+ QEMU_CAPS_DEVICE_QXL_VGA,
+ QEMU_CAPS_PCI_MULTIFUNCTION,
+ QEMU_CAPS_VIRTIO_IOEVENTFD,
+ QEMU_CAPS_SGA,
+ QEMU_CAPS_VIRTIO_BLK_EVENT_IDX,
+ QEMU_CAPS_VIRTIO_NET_EVENT_IDX,
+ QEMU_CAPS_VIRTIO_TX_ALG,
+ QEMU_CAPS_VIRTIO_IOEVENTFD,
+ QEMU_CAPS_PIIX3_USB_UHCI,
+ QEMU_CAPS_PIIX4_USB_UHCI,
+ QEMU_CAPS_USB_EHCI,
+ QEMU_CAPS_ICH9_USB_EHCI1,
+ QEMU_CAPS_USB_HUB,
+ QEMU_CAPS_NO_SHUTDOWN,
+ QEMU_CAPS_PCI_ROMBAR);
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
--
1.7.4.4
13 years, 1 month
[libvirt] [PATCH] Don't send back unknown program errors for async messages
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
If we send back an unknown program error for async messages,
we will confuse the client because they only expect replies
for method calls. Just log & drop any invalid async messages
* src/rpc/virnetserver.c: Don't send error for async messages
---
src/rpc/virnetserver.c | 23 +++++++++++++++++++----
src/rpc/virnetserverprogram.c | 13 ++++++++++++-
2 files changed, 31 insertions(+), 5 deletions(-)
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index 9588077..f739743 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -134,10 +134,25 @@ static void virNetServerHandleJob(void *jobOpaque, void *opaque)
srv, job->client, job->msg, job->prog);
if (!job->prog) {
- if (virNetServerProgramUnknownError(job->client,
- job->msg,
- &job->msg->header) < 0)
- goto error;
+ /* Only send back an error for type == CALL. Other
+ * message types are not expecting replies, so we
+ * must just log it & drop them
+ */
+ if (job->msg->header.type == VIR_NET_CALL) {
+ if (virNetServerProgramUnknownError(job->client,
+ job->msg,
+ &job->msg->header) < 0)
+ goto error;
+ } else {
+ VIR_INFO("Dropping client mesage, unknown program %d version %d type %d proc %d",
+ job->msg->header.prog, job->msg->header.vers,
+ job->msg->header.type, job->msg->header.proc);
+ /* Send a dummy reply to free up 'msg' & unblock client rx */
+ virNetMessageClear(job->msg);
+ job->msg->header.type = VIR_NET_REPLY;
+ if (virNetServerClientSendMessage(job->client, job->msg) < 0)
+ goto error;
+ }
goto cleanup;
}
diff --git a/src/rpc/virnetserverprogram.c b/src/rpc/virnetserverprogram.c
index 334a0bf..47b7ded 100644
--- a/src/rpc/virnetserverprogram.c
+++ b/src/rpc/virnetserverprogram.c
@@ -314,7 +314,18 @@ int virNetServerProgramDispatch(virNetServerProgramPtr prog,
return ret;
error:
- ret = virNetServerProgramSendReplyError(prog, client, msg, &rerr, &msg->header);
+ if (msg->header.type == VIR_NET_CALL) {
+ ret = virNetServerProgramSendReplyError(prog, client, msg, &rerr, &msg->header);
+ } else {
+ /* Send a dummy reply to free up 'msg' & unblock client rx */
+ virNetMessageClear(msg);
+ msg->header.type = VIR_NET_REPLY;
+ if (virNetServerClientSendMessage(client, msg) < 0) {
+ ret = -1;
+ goto cleanup;
+ }
+ ret = 0;
+ }
cleanup:
return ret;
--
1.7.6.2
13 years, 1 month
[libvirt] [PATCH] Fix deadlock when the RPC program is unknown
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
Commit 597fe3cee68f561a181967b59a87b4e5c5880c4c accidentally
introduced a deadlock when reporting an unknown RPC program.
The virNetServerDispatchNewMessage method is called with
the client locked, and must therefore not attempt to send
any RPC messages back to the client. Only once the incoming
message is passed off to the virNetServerHandleJob worker
is it safe to start sending messages back
* src/rpc/virnetserver.c: Delay checking for unknown RPC
program until in worker thread
---
src/rpc/virnetserver.c | 22 ++++++++++++++--------
1 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index d71ed18..9588077 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -133,6 +133,14 @@ static void virNetServerHandleJob(void *jobOpaque, void *opaque)
VIR_DEBUG("server=%p client=%p message=%p prog=%p",
srv, job->client, job->msg, job->prog);
+ if (!job->prog) {
+ if (virNetServerProgramUnknownError(job->client,
+ job->msg,
+ &job->msg->header) < 0)
+ goto error;
+ goto cleanup;
+ }
+
if (virNetServerProgramDispatch(job->prog,
srv,
job->client,
@@ -142,6 +150,8 @@ static void virNetServerHandleJob(void *jobOpaque, void *opaque)
virNetServerLock(srv);
virNetServerProgramFree(job->prog);
virNetServerUnlock(srv);
+
+cleanup:
virNetServerClientFree(job->client);
VIR_FREE(job);
return;
@@ -184,18 +194,14 @@ static int virNetServerDispatchNewMessage(virNetServerClientPtr client,
}
}
- if (!prog) {
- virNetServerProgramUnknownError(client, msg, &msg->header);
- goto cleanup;
+ if (prog) {
+ virNetServerProgramRef(prog);
+ job->prog = prog;
+ priority = virNetServerProgramGetPriority(prog, msg->header.proc);
}
- virNetServerProgramRef(prog);
- job->prog = prog;
- priority = virNetServerProgramGetPriority(prog, msg->header.proc);
-
ret = virThreadPoolSendJob(srv->workers, priority, job);
-cleanup:
if (ret < 0) {
VIR_FREE(job);
virNetServerProgramFree(prog);
--
1.7.6.2
13 years, 1 month
[libvirt] [PATCH v2 00/12] Implement keepalive protocol for libvirt RPC
by Jiri Denemark
This patchset can also be found at
https://gitorious.org/~jirka/libvirt/jirka-staging/commits/keepalive
This allows us to detect broken connections between server and client without
waiting for TCP timeout and dead deamon/client. By default a connection is
considered broken after about 30 seconds of no messages received from remote
party. After that period, the connection is automatically closed.
The main reason for implementing this is that peer-to-peer migration can now be
canceled when a connection between source and target breaks. Although this will
really work only after qemu fixes migrate_cancel command so that it doesn't
block when outgoing TCP buffers are full.
Version 2 adds virConnectIsAlive API and uses it to detect that a connection was
closed as a result of keepalive timeout.
The only patch that was changed in v2 is "Add keepalive support into
domain-events examples". All other patches are either new or without any change
from v1.
Jiri Denemark (12):
Define keepalive protocol
Implement common keepalive handling
Introduce two public APIs for keepalive protocol
Implement keepalive protocol in libvirt daemon
Add support for non-blocking calls in client RPC
Add support for async close of client RPC socket
Implement keepalive protocol in remote driver
Introduce virConnectIsAlive API
Implement virConnectIsAlive in all drivers
Add keepalive support into domain-events examples
qemu: Add support for keepalive messages during p2p migration
qemu: Cancel p2p migration when connection breaks
.gitignore | 1 +
daemon/libvirtd.aug | 4 +
daemon/libvirtd.c | 11 +
daemon/libvirtd.conf | 15 +
daemon/remote.c | 38 ++
examples/domain-events/events-c/event-test.c | 13 +-
examples/domain-events/events-python/event-test.py | 5 +-
include/libvirt/libvirt.h.in | 6 +
po/POTFILES.in | 1 +
src/Makefile.am | 13 +-
src/driver.h | 12 +
src/esx/esx_driver.c | 18 +
src/hyperv/hyperv_driver.c | 18 +
src/libvirt.c | 143 ++++++
src/libvirt_internal.h | 10 +-
src/libvirt_public.syms | 7 +
src/libxl/libxl_driver.c | 8 +
src/lxc/lxc_driver.c | 7 +
src/openvz/openvz_driver.c | 7 +
src/phyp/phyp_driver.c | 18 +
src/qemu/libvirtd_qemu.aug | 2 +
src/qemu/qemu.conf | 16 +
src/qemu/qemu_conf.c | 11 +
src/qemu/qemu_conf.h | 3 +
src/qemu/qemu_driver.c | 6 +
src/qemu/qemu_migration.c | 49 ++-
src/qemu/test_libvirtd_qemu.aug | 6 +
src/remote/remote_driver.c | 48 ++
src/remote/remote_protocol.x | 2 +-
src/rpc/virkeepalive.c | 464 ++++++++++++++++++++
src/rpc/virkeepalive.h | 58 +++
src/rpc/virkeepaliveprotocol.x | 8 +
src/rpc/virnetclient.c | 335 ++++++++++++--
src/rpc/virnetclient.h | 6 +
src/rpc/virnetserver.c | 10 +
src/rpc/virnetserver.h | 2 +
src/rpc/virnetserverclient.c | 126 +++++-
src/rpc/virnetserverclient.h | 6 +
src/test/test_driver.c | 6 +
src/uml/uml_driver.c | 7 +
src/vbox/vbox_tmpl.c | 6 +
src/vmware/vmware_driver.c | 7 +
src/xen/xen_driver.c | 8 +
src/xenapi/xenapi_driver.c | 12 +
44 files changed, 1483 insertions(+), 76 deletions(-)
create mode 100644 src/rpc/virkeepalive.c
create mode 100644 src/rpc/virkeepalive.h
create mode 100644 src/rpc/virkeepaliveprotocol.x
--
1.7.6.1
13 years, 1 month
[libvirt] [PATCH] Make saving domain XML more robust
by Jiri Denemark
When saving domain XML (either config or status) we just overwrite old
content of the file. In case something fails during that process (e.g.
disk gets full) we lose both old and new content. This patch makes the
process more robust by writing the new content into a separate file and
only if that succeeds the original file is atomically replaced with the
new one.
---
src/conf/domain_conf.c | 25 +++++++++++++++++++++----
1 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f9007ce..04c2b1c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -11025,6 +11025,7 @@ int virDomainSaveXML(const char *configDir,
const char *xml)
{
char *configFile = NULL;
+ char *newfile = NULL;
int fd = -1, ret = -1;
size_t towrite;
@@ -11038,12 +11039,17 @@ int virDomainSaveXML(const char *configDir,
goto cleanup;
}
- if ((fd = open(configFile,
+ if (virAsprintf(&newfile, "%s.new", configFile) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ if ((fd = open(newfile,
O_WRONLY | O_CREAT | O_TRUNC,
S_IRUSR | S_IWUSR )) < 0) {
virReportSystemError(errno,
_("cannot create config file '%s'"),
- configFile);
+ newfile);
goto cleanup;
}
@@ -11053,14 +11059,21 @@ int virDomainSaveXML(const char *configDir,
if (safewrite(fd, xml, towrite) < 0) {
virReportSystemError(errno,
_("cannot write config file '%s'"),
- configFile);
+ newfile);
goto cleanup;
}
if (VIR_CLOSE(fd) < 0) {
virReportSystemError(errno,
_("cannot save config file '%s'"),
- configFile);
+ newfile);
+ goto cleanup;
+ }
+
+ if (rename(newfile, configFile) < 0) {
+ virReportSystemError(errno,
+ _("cannot rename config file '%s' as '%s'"),
+ newfile, configFile);
goto cleanup;
}
@@ -11068,6 +11081,10 @@ int virDomainSaveXML(const char *configDir,
cleanup:
VIR_FORCE_CLOSE(fd);
+ if (newfile) {
+ unlink(newfile);
+ VIR_FREE(newfile);
+ }
VIR_FREE(configFile);
return ret;
}
--
1.7.7
13 years, 1 month
[libvirt] [PATCH] init: raise default system aio limits
by Eric Blake
https://bugzilla.redhat.com/show_bug.cgi?id=740899 documents that
if qemu uses aio=native for its disks, then it consumes 128 aio
requests per disk. On a host with multiple guests, this can quickly
run out of kernel aio requests with the default aio-max-nr of
65536. Kernel developers have confirmed that there is no up-front
cost to raising this limit (a larger limit merely implies that more
aio requests can be issued in parallel, which in turn will result
in more kernel memory allocation if the system really does use that
many requests). Since the system default limit prevents 256 disks,
which is well within libvirt's current scalability, this patch
installs a file to raise the limit and document it in case a system
administrator has further cause to tune the limit. The install
only works on platforms new enough to source /etc/sysctl.d/*
alongside /etc/sysctl.conf (F14 and RHEL 6).
* daemon/libvirtd.sysctl: New file.
* daemon/Makefile.am (EXTRA_DIST): Ship it.
(install-init, uninstall-init): Install it.
* libvirt.spec.in (%files): Include it in rpm.
---
So far, I've confirmed that this passes 'make distcheck' (well, once
https://www.redhat.com/archives/libvir-list/2011-October/msg00074.html
is applied) and 'make rpm', although I didn't actually try installing
the resulting rpm nor rebooting a system to see if it takes effect.
daemon/Makefile.am | 11 ++++++++---
daemon/libvirtd.sysctl | 8 ++++++++
libvirt.spec.in | 5 +++++
3 files changed, 21 insertions(+), 3 deletions(-)
create mode 100644 daemon/libvirtd.sysctl
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 690bf85..1cf2b73 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -38,6 +38,7 @@ EXTRA_DIST = \
libvirtd.policy-1 \
libvirtd.sasl \
libvirtd.sysconf \
+ libvirtd.sysctl \
libvirtd.aug \
libvirtd.logrotate.in \
libvirtd.qemu.logrotate.in \
@@ -252,16 +253,20 @@ install-logrotate: $(LOGROTATE_CONFS)
if LIBVIRT_INIT_SCRIPT_RED_HAT
install-init: libvirtd.init
- mkdir -p $(DESTDIR)$(sysconfdir)/rc.d/init.d
+ mkdir -p $(DESTDIR)$(sysconfdir)/rc.d/init.d \
+ $(DESTDIR)$(sysconfdir)/sysconfig \
+ $(DESTDIR)$(sysconfdir)/sysctl.d
$(INSTALL_SCRIPT) libvirtd.init \
$(DESTDIR)$(sysconfdir)/rc.d/init.d/libvirtd
- mkdir -p $(DESTDIR)$(sysconfdir)/sysconfig
$(INSTALL_DATA) $(srcdir)/libvirtd.sysconf \
$(DESTDIR)$(sysconfdir)/sysconfig/libvirtd
+ $(INSTALL_DATA) $(srcdir)/libvirtd.sysctl \
+ $(DESTDIR)$(sysconfdir)/sysctl.d/libvirtd
uninstall-init:
rm -f $(DESTDIR)$(sysconfdir)/rc.d/init.d/libvirtd \
- $(DESTDIR)$(sysconfdir)/sysconfig/libvirtd
+ $(DESTDIR)$(sysconfdir)/sysconfig/libvirtd \
+ $(DESTDIR)$(sysconfdir)/sysctl.d/libvirtd
BUILT_SOURCES += libvirtd.init
diff --git a/daemon/libvirtd.sysctl b/daemon/libvirtd.sysctl
new file mode 100644
index 0000000..3c70884
--- /dev/null
+++ b/daemon/libvirtd.sysctl
@@ -0,0 +1,8 @@
+# The kernel allocates aio memory on demand, and this number limits the
+# number of parallel aio requests; the only drawback of a larger limit is
+# that a malicious guest could issue parallel requests to cause the kernel
+# to set aside memory. Set this number at least as large as
+# 128 * (number of virtual disks on the host)
+# Libvirt uses a default of 1M requests to allow 8k disks, with at most
+# 64M of kernel memory if all disks hit an aio request at the same time.
+fs.aio-max-size = 1048576
diff --git a/libvirt.spec.in b/libvirt.spec.in
index b87e3f6..9f5797a 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -962,6 +962,11 @@ fi
%doc daemon/libvirtd.upstart
%config(noreplace) %{_sysconfdir}/sysconfig/libvirtd
%config(noreplace) %{_sysconfdir}/libvirt/libvirtd.conf
+%if 0%{?fedora} >= 14 || 0%{?rhel} >= 6
+%config(noreplace) %{_sysconfdir}/sysctl.d/libvirtd
+%else
+rm -f $RPM_BUILD_ROOT%{_sysconfdir}/sysctl.d/libvirtd
+%endif
%if %{with_dtrace}
%{_datadir}/systemtap/tapset/libvirtd.stp
%endif
--
1.7.4.4
13 years, 1 month
[libvirt] [PATCH] maint: fix minor issues in virterror public header
by Eric Blake
Consistent use of tabs, fewer long lines, and a typo fix.
* include/libvirt/virterror.h: Fix typos, layout.
---
Pushing under the trivial rule.
include/libvirt/virterror.h | 19 ++++++++++---------
1 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h
index 0c98014..dfbe2bc 100644
--- a/include/libvirt/virterror.h
+++ b/include/libvirt/virterror.h
@@ -66,7 +66,8 @@ typedef enum {
VIR_FROM_SECURITY = 24, /* Error from security framework */
VIR_FROM_VBOX = 25, /* Error from VirtualBox driver */
VIR_FROM_INTERFACE = 26, /* Error when operating on an interface */
- VIR_FROM_ONE = 27, /* The OpenNebula driver no longer exists. Retained for ABI/API compat only */
+ VIR_FROM_ONE = 27, /* The OpenNebula driver no longer exists.
+ Retained for ABI/API compat only */
VIR_FROM_ESX = 28, /* Error from ESX driver */
VIR_FROM_PHYP = 29, /* Error from IBM power hypervisor */
VIR_FROM_SECRET = 30, /* Error from secret storage */
@@ -79,10 +80,10 @@ typedef enum {
VIR_FROM_SYSINFO = 37, /* Error from sysinfo/SMBIOS */
VIR_FROM_STREAMS = 38, /* Error from I/O streams */
VIR_FROM_VMWARE = 39, /* Error from VMware driver */
- VIR_FROM_EVENT = 40, /* Error from event loop impl */
+ VIR_FROM_EVENT = 40, /* Error from event loop impl */
VIR_FROM_LIBXL = 41, /* Error from libxenlight driver */
- VIR_FROM_LOCKING = 42, /* Error from lock manager */
- VIR_FROM_HYPERV = 43, /* Error from Hyper-V driver */
+ VIR_FROM_LOCKING = 42, /* Error from lock manager */
+ VIR_FROM_HYPERV = 43, /* Error from Hyper-V driver */
} virErrorDomain;
@@ -232,12 +233,12 @@ typedef enum {
VIR_ERR_HOOK_SCRIPT_FAILED = 70, /* a synchronous hook script failed */
VIR_ERR_INVALID_DOMAIN_SNAPSHOT = 71,/* invalid domain snapshot */
VIR_ERR_NO_DOMAIN_SNAPSHOT = 72, /* domain snapshot not found */
- VIR_ERR_INVALID_STREAM = 73, /* stream pointer not valid */
- VIR_ERR_ARGUMENT_UNSUPPORTED = 74, /* valid API use but unsupported by
+ VIR_ERR_INVALID_STREAM = 73, /* stream pointer not valid */
+ VIR_ERR_ARGUMENT_UNSUPPORTED = 74, /* valid API use but unsupported by
the given driver */
- VIR_ERR_STORAGE_PROBE_FAILED = 75, /* storage pool proble failed */
- VIR_ERR_STORAGE_POOL_BUILT = 76, /* storage pool already built */
- VIR_ERR_SNAPSHOT_REVERT_RISKY = 77, /* force was not requested for a
+ VIR_ERR_STORAGE_PROBE_FAILED = 75, /* storage pool probe failed */
+ VIR_ERR_STORAGE_POOL_BUILT = 76, /* storage pool already built */
+ VIR_ERR_SNAPSHOT_REVERT_RISKY = 77, /* force was not requested for a
risky domain snapshot revert */
} virErrorNumber;
--
1.7.4.4
13 years, 1 month
[libvirt] [RFC PATCHv2 0/9] DHCP snooping support for libvirt.
by David L Stevens
This series of patches adds DHCP snooping support to libvirt. This version
saves leases on disk for restoration after a libvirtd restart and allows
selection of different ip_learning methods by setting filter parameter
"ip_learning" to one of "any" (existing IP learning code) "none" (static only
addresses) or "DHCP" (DHCP Snooping).
This code does not (yet) support passing lease information across a migration.
A migrated guest requires a DHCP ACK (e.g., via ifdown/ifup on the guest) to
send/receive traffic for DHCP-learned addresses after a migration.
David L Stevens (9):
support continue/return
allow required ARP packets
reverse sense of address matching
make default chain policy "DROP"
allow chain modification
support addRules
support variable value changing
add DHCP snooping
add leasefile support
examples/xml/nwfilter/Makefile.am | 5 +-
examples/xml/nwfilter/allow-arp.xml | 5 +-
examples/xml/nwfilter/allow-arpip.xml | 3 +
examples/xml/nwfilter/allow-arpmac.xml | 3 +
examples/xml/nwfilter/clean-traffic.xml | 6 +-
examples/xml/nwfilter/no-arp-spoofing.xml | 38 +-
examples/xml/nwfilter/no-arpip-spoofing.xml | 10 +
examples/xml/nwfilter/no-arpmac-spoofing.xml | 5 +
examples/xml/nwfilter/no-ip-spoofing.xml | 9 +-
examples/xml/nwfilter/no-mac-spoofing.xml | 10 +-
examples/xml/nwfilter/no-other-l2-traffic.xml | 13 +-
examples/xml/nwfilter/no-other-rarp-traffic.xml | 3 -
examples/xml/nwfilter/qemu-announce-self.xml | 1 -
src/Makefile.am | 2 +
src/conf/nwfilter_conf.c | 12 +-
src/conf/nwfilter_conf.h | 16 +-
src/nwfilter/nwfilter_dhcpsnoop.c | 938 +++++++++++++++++++++++
src/nwfilter/nwfilter_dhcpsnoop.h | 36 +
src/nwfilter/nwfilter_driver.c | 5 +
src/nwfilter/nwfilter_ebiptables_driver.c | 225 +++++--
src/nwfilter/nwfilter_gentech_driver.c | 199 ++++-
src/nwfilter/nwfilter_gentech_driver.h | 11 +
22 files changed, 1419 insertions(+), 136 deletions(-)
create mode 100644 examples/xml/nwfilter/allow-arpip.xml
create mode 100644 examples/xml/nwfilter/allow-arpmac.xml
create mode 100644 examples/xml/nwfilter/no-arpip-spoofing.xml
create mode 100644 examples/xml/nwfilter/no-arpmac-spoofing.xml
delete mode 100644 examples/xml/nwfilter/no-other-rarp-traffic.xml
create mode 100644 src/nwfilter/nwfilter_dhcpsnoop.c
create mode 100644 src/nwfilter/nwfilter_dhcpsnoop.h
--
1.7.6.4
13 years, 1 month
[libvirt] [PATCH 0/2] snapshot: add force for risky reverts
by Eric Blake
I first documented the need for force back in my RFC:
https://www.redhat.com/archives/libvir-list/2011-August/msg00361.html
but only now got around to implementing it.
At the moment, I'm posting the code for early review. I'm still
in the process of testing out multiple scenarios, and will send
followup mail detailing the actual steps I took using virsh to
cover the multiple scenarios.
Eric Blake (2):
snapshot: add REVERT_FORCE to API
snapshot: enforce REVERT_FORCE on qemu
include/libvirt/libvirt.h.in | 1 +
include/libvirt/virterror.h | 2 +
src/libvirt.c | 22 +++++++++++++++++++
src/qemu/qemu_driver.c | 47 +++++++++++++++++++++++++++++++++---------
src/util/virterror.c | 6 +++++
tools/virsh.c | 19 ++++++++++++++++-
tools/virsh.pod | 17 +++++++++++++++
7 files changed, 103 insertions(+), 11 deletions(-)
--
1.7.4.4
13 years, 1 month
[libvirt] [PATCH] qemu: Don't fail virDomainGetInfo if we can't update balloon info
by Jiri Denemark
Qemu driver tries to update balloon data in virDomainGetInfo and if it
can't do so because there is another monitor job running, it just
reports what's known in domain def. However, if there was no job running
but getting the data from qemu fails, we would fail the whole API. This
doesn't make sense. Let's make the failure nonfatal.
---
src/qemu/qemu_driver.c | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index dc34e1d..276dc06 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2071,37 +2071,42 @@ static int qemudDomainGetInfo(virDomainPtr dom,
} else if (qemuDomainJobAllowed(priv, QEMU_JOB_QUERY)) {
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0)
goto cleanup;
if (!virDomainObjIsActive(vm))
err = 0;
else {
qemuDomainObjEnterMonitor(driver, vm);
err = qemuMonitorGetBalloonInfo(priv->mon, &balloon);
qemuDomainObjExitMonitor(driver, vm);
}
if (qemuDomainObjEndJob(driver, vm) == 0) {
vm = NULL;
goto cleanup;
}
- if (err < 0)
- goto cleanup;
- if (err == 0)
+ if (err < 0) {
+ /* We couldn't get current memory allocation but that's not
+ * a show stopper; we wouldn't get it if there was a job
+ * active either
+ */
+ info->memory = vm->def->mem.cur_balloon;
+ } else if (err == 0) {
/* Balloon not supported, so maxmem is always the allocation */
info->memory = vm->def->mem.max_balloon;
- else
+ } else {
info->memory = balloon;
+ }
} else {
info->memory = vm->def->mem.cur_balloon;
}
} else {
info->memory = vm->def->mem.cur_balloon;
}
info->nrVirtCpu = vm->def->vcpus;
ret = 0;
cleanup:
if (vm)
virDomainObjUnlock(vm);
return ret;
}
--
1.7.7
13 years, 1 month