[libvirt] [PATCH] qemu: Fix detection of drive readonly option
by Jiri Denemark
So far, readonly=on option is used when qemu supports -device. However,
there are qemu versions which support readonly option with -drive
although they don't have support for -device.
---
src/qemu/qemu_conf.c | 12 ++-
src/qemu/qemu_conf.h | 1 +
tests/qemuhelpdata/kvm-83-rhel56 | 141 ++++++++++++++++++++
tests/qemuhelptest.c | 26 ++++
...qemuxml2argv-disk-drive-readonly-no-device.args | 1 +
.../qemuxml2argv-disk-drive-readonly-no-device.xml | 31 +++++
tests/qemuxml2argvtest.c | 5 +-
7 files changed, 214 insertions(+), 3 deletions(-)
create mode 100644 tests/qemuhelpdata/kvm-83-rhel56
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-readonly-no-device.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-readonly-no-device.xml
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index e2c67a3..00e89a1 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1187,6 +1187,8 @@ static unsigned long long qemudComputeCmdFlags(const char *help,
flags |= QEMUD_CMD_FLAG_DRIVE_CACHE_V2;
if (strstr(help, "format="))
flags |= QEMUD_CMD_FLAG_DRIVE_FORMAT;
+ if (strstr(help, "readonly="))
+ flags |= QEMUD_CMD_FLAG_DRIVE_READONLY;
}
if (strstr(help, "-vga") && !strstr(help, "-std-vga"))
flags |= QEMUD_CMD_FLAG_VGA;
@@ -1202,8 +1204,14 @@ static unsigned long long qemudComputeCmdFlags(const char *help,
flags |= QEMUD_CMD_FLAG_CHARDEV;
if (strstr(help, "-balloon"))
flags |= QEMUD_CMD_FLAG_BALLOON;
- if (strstr(help, "-device"))
+ if (strstr(help, "-device")) {
flags |= QEMUD_CMD_FLAG_DEVICE;
+ /*
+ * When -device was introduced, qemu already supported drive's
+ * readonly option but didn't advertise that.
+ */
+ flags |= QEMUD_CMD_FLAG_DRIVE_READONLY;
+ }
if (strstr(help, "-nodefconfig"))
flags |= QEMUD_CMD_FLAG_NODEFCONFIG;
/* The trailing ' ' is important to avoid a bogus match */
@@ -2688,7 +2696,7 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
disk->bus != VIR_DOMAIN_DISK_BUS_IDE)
virBufferAddLit(&opt, ",boot=on");
if (disk->readonly &&
- qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)
+ qemuCmdFlags & QEMUD_CMD_FLAG_DRIVE_READONLY)
virBufferAddLit(&opt, ",readonly=on");
if (disk->driverType && *disk->driverType != '\0' &&
disk->type != VIR_DOMAIN_DISK_TYPE_DIR &&
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index 005031d..530dcdb 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -96,6 +96,7 @@ enum qemud_cmd_flags {
QEMUD_CMD_FLAG_FSDEV = (1LL << 40), /* -fstype filesystem passthrough */
QEMUD_CMD_FLAG_NESTING = (1LL << 41), /* -enable-nesting (SVM/VMX) */
QEMUD_CMD_FLAG_NAME_PROCESS = (1LL << 42), /* Is -name process= available */
+ QEMUD_CMD_FLAG_DRIVE_READONLY = (1LL << 43), /* -drive readonly=on|off */
};
/* Main driver state */
diff --git a/tests/qemuhelpdata/kvm-83-rhel56 b/tests/qemuhelpdata/kvm-83-rhel56
new file mode 100644
index 0000000..b2cefa9
--- /dev/null
+++ b/tests/qemuhelpdata/kvm-83-rhel56
@@ -0,0 +1,141 @@
+QEMU PC emulator version 0.9.1 (kvm-83-maint-snapshot-20090205), Copyright (c) 2003-2008 Fabrice Bellard
+usage: qemu [options] [disk_image]
+
+'disk_image' is a raw hard image image for IDE hard disk 0
+
+Standard options:
+-M machine select emulated machine (-M ? for list)
+-cpu cpu select CPU (-cpu ? for list)
+-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]
+ [,boot=on|off][,readonly=on|off]
+ use 'file' as a drive image
+-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 [a|c|d|n] boot on floppy (a), hard disk (c), CD-ROM (d), or network (n)
+-snapshot write to temporary files instead of disk image files
+-no-frame open SDL window without a frame and window decorations
+-alt-grab use Ctrl-Alt-Shift to grab mouse (instead of Ctrl-Alt)
+-no-quit disable SDL window close capability
+-no-fd-bootchk disable boot signature checking for floppy disks
+-m megs set virtual RAM size to megs MB [default=128]
+-smp n set the number of CPUs to 'n' [default=1]
+-nographic disable graphical output and redirect serial I/Os to console
+-portrait rotate graphical output 90 deg left (only PXA LCD)
+-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
+-vga [std|cirrus]
+ select video card type
+-localtime set the real time clock to local time [default=utc]
+-full-screen start in full screen
+-win2k-hack use it when installing Windows 2000 to avoid a disk full bug
+-rtc-td-hack use it to fix time drift in Windows ACPI HAL
+-usb enable the USB driver (will be the default soon)
+-usbdevice name add the host or guest USB device 'name'
+-name string set the name of the guest
+-uuid %08x-%04x-%04x-%04x-%012x specify machine UUID
+-notify event enable async-notifications for event
+-qxl <num>[,ram=megs]
+ use 'num' qxl display devices, each with RAM size of 'megs' MB
+ [default=64]
+-spice <args> use spice
+-spice-help show spice usage
+
+Network options:
+-net nic[,vlan=n][,macaddr=addr][,model=type][,name=str]
+ create a new Network Interface Card and connect it to VLAN 'n'
+-net user[,vlan=n][,name=str][,hostname=host]
+ connect the user mode network stack to VLAN 'n' and send
+ hostname 'host' to DHCP clients
+-net tap[,vlan=n][,name=str][,fd=h][,ifname=name][,script=file][,downscript=dfile]
+ 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
+-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 none use it alone to have zero network devices; if no -net option
+ is provided, the default is '-net nic -net user'
+
+-tftp dir allow tftp access to files in dir [-net user]
+-bootp file advertise file in BOOTP replies
+-redir [tcp|udp]:host-port:[guest-host]:guest-port
+ redirect TCP or UDP connections from host to guest [-net user]
+
+Linux 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:
+-monitor dev redirect the monitor to char device 'dev'
+-vmchannel di:DI,dev redirect the hypercall device with device id DI, to char device 'dev'
+-serial dev redirect the serial port to char device 'dev'
+-parallel dev redirect the parallel port to char device 'dev'
+-pidfile file Write PID to 'file'
+-S freeze CPU at startup (use 'c' to start execution)
+-s wait gdb connection to port
+-p port set gdb connection port [default=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
+-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.
+-no-acpi disable ACPI
+-no-hpet disable HPET
+-balloon none disable balloon device
+-balloon virtio
+ 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
+-no-reboot exit instead of rebooting
+-no-shutdown stop before shutdown
+-loadvm [tag|id] start right away with a saved state (loadvm in monitor)
+-vnc display start a VNC server on display
+-daemonize daemonize QEMU after initializing
+-tdf inject timer interrupts that got lost
+-kvm-shadow-memory megs set the amount of shadow pages to be allocated
+-mem-path set the path to hugetlbfs/tmpfs mounted directory, also
+ enables allocation of guest memory with huge pages
+-mem-prealloc toggles preallocation of -mem-path backed physical memory
+ at startup. Default is enabled.
+-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 ?
+-startdate select initial date of the clock
+-icount [N|auto]
+ Enable virtual instruction counter with 2^N clock ticks per instruction
+
+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.
diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c
index d4453db..97531ff 100644
--- a/tests/qemuhelptest.c
+++ b/tests/qemuhelptest.c
@@ -130,6 +130,30 @@ mymain(int argc, char **argv)
QEMUD_CMD_FLAG_MEM_PATH |
QEMUD_CMD_FLAG_TDF,
9001, 1, 74);
+ DO_TEST("kvm-83-rhel56",
+ QEMUD_CMD_FLAG_VNC_COLON |
+ QEMUD_CMD_FLAG_NO_REBOOT |
+ QEMUD_CMD_FLAG_DRIVE |
+ QEMUD_CMD_FLAG_DRIVE_BOOT |
+ QEMUD_CMD_FLAG_NAME |
+ QEMUD_CMD_FLAG_UUID |
+ QEMUD_CMD_FLAG_VNET_HDR |
+ QEMUD_CMD_FLAG_MIGRATE_QEMU_TCP |
+ QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC |
+ QEMUD_CMD_FLAG_DRIVE_CACHE_V2 |
+ QEMUD_CMD_FLAG_KVM |
+ QEMUD_CMD_FLAG_DRIVE_FORMAT |
+ QEMUD_CMD_FLAG_DRIVE_SERIAL |
+ QEMUD_CMD_FLAG_VGA |
+ QEMUD_CMD_FLAG_PCIDEVICE |
+ QEMUD_CMD_FLAG_MEM_PATH |
+ QEMUD_CMD_FLAG_BALLOON |
+ QEMUD_CMD_FLAG_RTC_TD_HACK |
+ QEMUD_CMD_FLAG_NO_HPET |
+ QEMUD_CMD_FLAG_NO_KVM_PIT |
+ QEMUD_CMD_FLAG_TDF |
+ QEMUD_CMD_FLAG_DRIVE_READONLY,
+ 9001, 1, 83);
DO_TEST("qemu-0.10.5",
QEMUD_CMD_FLAG_KQEMU |
QEMUD_CMD_FLAG_VNC_COLON |
@@ -238,6 +262,7 @@ mymain(int argc, char **argv)
QEMUD_CMD_FLAG_DRIVE_CACHE_V2 |
QEMUD_CMD_FLAG_DRIVE_FORMAT |
QEMUD_CMD_FLAG_DRIVE_SERIAL |
+ QEMUD_CMD_FLAG_DRIVE_READONLY |
QEMUD_CMD_FLAG_VGA |
QEMUD_CMD_FLAG_0_10 |
QEMUD_CMD_FLAG_ENABLE_KVM |
@@ -267,6 +292,7 @@ mymain(int argc, char **argv)
QEMUD_CMD_FLAG_KVM |
QEMUD_CMD_FLAG_DRIVE_FORMAT |
QEMUD_CMD_FLAG_DRIVE_SERIAL |
+ QEMUD_CMD_FLAG_DRIVE_READONLY |
QEMUD_CMD_FLAG_VGA |
QEMUD_CMD_FLAG_0_10 |
QEMUD_CMD_FLAG_PCIDEVICE |
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-readonly-no-device.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-readonly-no-device.args
new file mode 100644
index 0000000..fb99a7c
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-readonly-no-device.args
@@ -0,0 +1 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -drive file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0 -drive file=/dev/sr0,if=ide,media=cdrom,bus=1,unit=0,readonly=on -net none -serial none -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-readonly-no-device.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-readonly-no-device.xml
new file mode 100644
index 0000000..1f193c9
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-readonly-no-device.xml
@@ -0,0 +1,31 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219200</memory>
+ <currentMemory>219200</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' unit='0'/>
+ </disk>
+ <disk type='block' device='cdrom'>
+ <source dev='/dev/sr0'/>
+ <target dev='hdc' bus='ide'/>
+ <readonly/>
+ <address type='drive' controller='0' bus='1' unit='0'/>
+ </disk>
+ <controller type='ide' index='0'/>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 4eb3cc6..f719f12 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -276,7 +276,10 @@ mymain(int argc, char **argv)
DO_TEST("disk-drive-fat", QEMUD_CMD_FLAG_DRIVE |
QEMUD_CMD_FLAG_DRIVE_BOOT | QEMUD_CMD_FLAG_DRIVE_FORMAT, false);
DO_TEST("disk-drive-readonly-disk", QEMUD_CMD_FLAG_DRIVE |
- QEMUD_CMD_FLAG_DEVICE | QEMUD_CMD_FLAG_NODEFCONFIG, false);
+ QEMUD_CMD_FLAG_DRIVE_READONLY | QEMUD_CMD_FLAG_DEVICE |
+ QEMUD_CMD_FLAG_NODEFCONFIG, false);
+ DO_TEST("disk-drive-readonly-no-device", QEMUD_CMD_FLAG_DRIVE |
+ QEMUD_CMD_FLAG_DRIVE_READONLY | QEMUD_CMD_FLAG_NODEFCONFIG, false);
DO_TEST("disk-drive-fmt-qcow", QEMUD_CMD_FLAG_DRIVE |
QEMUD_CMD_FLAG_DRIVE_BOOT | QEMUD_CMD_FLAG_DRIVE_FORMAT, false);
DO_TEST("disk-drive-shared", QEMUD_CMD_FLAG_DRIVE |
--
1.7.3.2
14 years, 1 month
[libvirt] [PATCH] Don't use %.3d format for bus/addr of USB devices.
by Diego Elio Pettenò
When using 0-prefixed numbers, QEmu will interpret them as octal numbers
(as C convention says); this means that if you attach a device that has
addr > 10 (decimal) you're going to attach a different device.
---
src/qemu/qemu_conf.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 00e89a1..5bd3d4c 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -3266,7 +3266,7 @@ qemuBuildUSBHostdevDevStr(virDomainHostdevDefPtr dev)
return NULL;
}
- if (virAsprintf(&ret, "usb-host,hostbus=%.3d,hostaddr=%.3d,id=%s",
+ if (virAsprintf(&ret, "usb-host,hostbus=%d,hostaddr=%d,id=%s",
dev->source.subsys.u.usb.bus,
dev->source.subsys.u.usb.device,
dev->info.alias) < 0)
@@ -3288,7 +3288,7 @@ qemuBuildUSBHostdevUsbDevStr(virDomainHostdevDefPtr dev)
return NULL;
}
- if (virAsprintf(&ret, "host:%.3d.%.3d",
+ if (virAsprintf(&ret, "host:%d.%d",
dev->source.subsys.u.usb.bus,
dev->source.subsys.u.usb.device) < 0)
virReportOOMError();
--
1.7.3.2
14 years, 1 month
[libvirt] [PATCH] virsh: consolidate memtune docs
by Eric Blake
* tools/virsh.pod (memtune): Drop second copy, fill to 80 columns,
enhance wording.
---
Seeing memtune twice in the man page is a bit confusing.
This patch doesn't touch the pending issue of whether --min_guarantee
makes sense, or should be deleted before it becomes a pre-mature
API addition.
Also, should memtune be changed to use VSH_OT_INT rather than
VSH_OT_STRING? The current 'virsh help memtune' output looks
weird:
OPTIONS
[--domain] <string> domain name, id or uuid
--hard_limit <string> Max memory in kilobytes
--soft_limit <string> Memory during contention in kilobytes
--swap_hard_limit <string> Max swap in kilobytes
--min_guarantee <string> Min guaranteed memory in kilobytes
tools/virsh.pod | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 943a563..bc68146 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -513,13 +513,14 @@ Change the maximum memory allocation limit in the guest domain. This should
not change the current memory use. The memory limit is specified in
kilobytes.
-=item B<memtune> I<domain-id>
-
-Displays the domain memory parameters.
-
-=item B<memtune> I<domain-id> optional I<--hard-limit> B<kilobytes> optional I<--soft-limit> B<kilobytes> optional I<--swap-hard-limit> B<kilobytes> -I<--min-guarantee> B<kilobytes>
-
-Allows you to set the domain memory parameters. LXC and QEMU/KVM supports these parameters.
+=item B<memtune> I<domain-id> optional I<--hard-limit> B<kilobytes>
+optional I<--soft-limit> B<kilobytes> optional I<--swap-hard-limit>
+B<kilobytes> -I<--min-guarantee> B<kilobytes>
+
+Allows you to display or set the domain memory parameters. Without
+flags, the current settings are displayed; with a flag, the
+appropriate limit is adjusted if supported by the hypervisor. LXC and
+QEMU/KVM supports I<--hard-limit>, I<--soft-limit>, and I<--swap-hard-limit>.
=item B<setvcpus> I<domain-id> I<count>
--
1.7.2.3
14 years, 1 month
[libvirt] [PATCH v4 00/13] Implement memory control api
by Nikunj A. Dadhania
Changelog from v3:
* Add unsigned int flags to the public api and make corresponding changes
further down till the drivers(qemu, lxc and remote)
* Move exporting of the api's to patch two
* Added memtune test in tests/qemuxml2xmltest.c
* Fix: src/conf/domain_conf.c - print memtune element only if tunable
is present
* Fix: src/qemu/qemu_driver.c - call cgroup apis only if nonzero
* Fix: src/lxc/lxc_controller.c - call cgroup apis only if nonzero
Changelog from v2:
* Implement virDomainGetMemoryParameters api
* Add virDomainGetMemoryParameters to memtune command in virsh
* Provide domainGetMemoryParameters implementation for remote, QEmu and LXC
drivers
* Auto-generate code using rpcgen and remote_generate_stubs.pl
* Squash all the changes related to remote driver and remote protocol into
one single patch.
* Patch re-ordering
Changelog from v1:
* Patch re-ordering for compilation
* Folded python bindings changes to patch 01
* Added defines for string constants for memory tunables
* Typo fix: min_guarantee
* Moved initialization of function pointers in driver.h patch
This patch series implement public api for controlling various memory tunables
exported by the OS. This is based on the following RFC[1].
* Implement virDomainSetMemoryParameters api
* Provide implementation for remote, QEmu and LXC drivers
* Enable memory controller support fro QEmu
* virsh command for runtime changes to the memory parameters
* Domain configuration parsing for memory control parameters
* Cgroup memory controller code for memory hard_limit/soft_limit, swap
hard_limit
To Do
* Python bindings is just a place holder, need to implement
1. https://www.redhat.com/archives/libvir-list/2010-August/msg00607.html
2. https://www.redhat.com/archives/libvir-list/2010-August/msg00699.html
---
Nikunj A. Dadhania (13):
Adding structure and defines for virDomainSet/GetMemoryParameters
Adding virDomainSetMemoryParameters and virDomainGetMemoryParameters API
Adds xml entries for memory tunables
XML parsing for memory tunables
Implement cgroup memory controller tunables
Implement driver interface domainSetMemoryParamters for QEmu
Implement driver interface domainGetMemoryParamters for QEmu
Adding memtunables to qemuSetupCgroup
Adding memtunables to libvirt-lxc command
Implement driver interface domainSetMemoryParamters for LXC
Implement driver interface domainGetMemoryParamters for LXC
Adding memtune command to virsh tool
Remote protocol changes and implements virDomainSet/GetMemoryParameters
daemon/remote.c | 162 +++++++++++++
daemon/remote_dispatch_args.h | 2
daemon/remote_dispatch_prototypes.h | 16 +
daemon/remote_dispatch_ret.h | 1
daemon/remote_dispatch_table.h | 10 +
docs/schemas/domain.rng | 31 +++
include/libvirt/libvirt.h.in | 63 +++++
python/generator.py | 2
python/libvirt-override-api.xml | 12 +
python/libvirt-override.c | 14 +
src/conf/domain_conf.c | 54 ++++
src/conf/domain_conf.h | 12 +
src/driver.h | 14 +
src/esx/esx_driver.c | 2
src/esx/esx_vmx.c | 30 +-
src/libvirt.c | 104 +++++++++
src/libvirt_private.syms | 6
src/libvirt_public.syms | 6
src/lxc/lxc_controller.c | 32 +++
src/lxc/lxc_driver.c | 215 +++++++++++++++++-
src/openvz/openvz_driver.c | 10 -
src/phyp/phyp_driver.c | 2
src/qemu/qemu.conf | 4
src/qemu/qemu_conf.c | 11 -
src/qemu/qemu_driver.c | 265 +++++++++++++++++++++-
src/remote/remote_driver.c | 151 +++++++++++++
src/remote/remote_protocol.c | 88 +++++++
src/remote/remote_protocol.h | 58 +++++
src/remote/remote_protocol.x | 44 ++++
src/test/test_driver.c | 14 +
src/uml/uml_conf.c | 2
src/uml/uml_driver.c | 16 +
src/util/cgroup.c | 106 +++++++++
src/util/cgroup.h | 7 +
src/xen/xen_driver.c | 2
tests/qemuxml2argvdata/qemuxml2argv-memtune.args | 1
tests/qemuxml2argvdata/qemuxml2argv-memtune.xml | 30 ++
tests/qemuxml2xmltest.c | 1
tools/virsh.c | 130 +++++++++++
39 files changed, 1662 insertions(+), 68 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-memtune.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-memtune.xml
14 years, 1 month
[libvirt] [PATCH] docs: make the location of the xml catalog file a configure option
by Justin Clift
The default location for the XML catalog file, /etc/xml/catalog,
used when validating the generated html docs, isn't correct for
MacOS X.
This commit adds an option to the configure script, allowing the
default to be overridden:
--with-xml-catalog-file=/path/to/xml/catalog/file
---
Tested on MacOS X 10.6 (using overridden locatin), and Fedora 13 (using the
default location). Works fine on both.
configure.ac | 17 ++++++++++++-----
docs/Makefile.am | 10 ++++++----
2 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/configure.ac b/configure.ac
index e41f2b5..153fa1f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -171,6 +171,12 @@ AC_ARG_WITH([html-subdir], [AC_HELP_STRING([--with-html-subdir=path],
[HTML_DIR="$HTML_DIR/\$(PACKAGE)-\$(VERSION)/html"])
AC_SUBST([HTML_DIR])
+dnl Specific XML catalog file for validation of generated html
+AC_ARG_WITH([xml-catalog-file], [AC_HELP_STRING([--with-xml-catalog-file=path],
+ [path to XML catalog file for validating generated html, default /etc/xml/catalog])],
+ [XML_CATALOG_FILE=$withval], [XML_CATALOG_FILE='/etc/xml/catalog'])
+AC_SUBST([XML_CATALOG_FILE])
+
dnl if --prefix is /usr, don't use /usr/var for localstatedir
dnl or /usr/etc for sysconfdir
dnl as this makes a lot of things break in testing situations
@@ -2416,11 +2422,12 @@ AC_MSG_NOTICE([ Alloc OOM: $enable_oom])
AC_MSG_NOTICE([])
AC_MSG_NOTICE([Miscellaneous])
AC_MSG_NOTICE([])
-AC_MSG_NOTICE([ Debug: $enable_debug])
-AC_MSG_NOTICE([ Warnings: $enable_compile_warnings])
-AC_MSG_NOTICE([ Readline: $lv_use_readline])
-AC_MSG_NOTICE([ Python: $with_python])
-AC_MSG_NOTICE([ DTrace: $with_dtrace])
+AC_MSG_NOTICE([ Debug: $enable_debug])
+AC_MSG_NOTICE([ Warnings: $enable_compile_warnings])
+AC_MSG_NOTICE([ Readline: $lv_use_readline])
+AC_MSG_NOTICE([ Python: $with_python])
+AC_MSG_NOTICE([ DTrace: $with_dtrace])
+AC_MSG_NOTICE([ XML Catalog: $XML_CATALOG_FILE])
AC_MSG_NOTICE([])
AC_MSG_NOTICE([Privileges])
AC_MSG_NOTICE([])
diff --git a/docs/Makefile.am b/docs/Makefile.am
index ae13c46..27804a2 100644
--- a/docs/Makefile.am
+++ b/docs/Makefile.am
@@ -118,10 +118,11 @@ todo:
%.html: %.html.tmp
@if test -x $(XMLLINT) && test -x $(XMLCATALOG) ; then \
- if $(XMLCATALOG) /etc/xml/catalog \
+ if $(XMLCATALOG) $(XML_CATALOG_FILE) \
"-//W3C//DTD XHTML 1.0 Strict//EN" > /dev/null ; then \
echo "Validating $@" ; \
- $(XMLLINT) --nonet --format --valid $< > $@ \
+ SGML_CATALOG_FILES=$(XML_CATALOG_FILE) \
+ $(XMLLINT) --catalogs --nonet --format --valid $< > $@ \
|| { rm $@ && exit 1; }; \
else echo "missing XHTML1 DTD" ; fi ; fi
@@ -131,10 +132,11 @@ html/index.html: libvirt-api.xml newapi.xsl page.xsl sitemap.html.in
echo "Rebuilding the HTML pages from the XML API" ; \
$(XSLTPROC) --nonet $(srcdir)/newapi.xsl libvirt-api.xml ; fi
-@if test -x $(XMLLINT) && test -x $(XMLCATALOG) ; then \
- if $(XMLCATALOG) /etc/xml/catalog "-//W3C//DTD XHTML 1.0 Strict//EN" \
+ if $(XMLCATALOG) $(XML_CATALOG_FILE) "-//W3C//DTD XHTML 1.0 Strict//EN" \
> /dev/null ; then \
echo "Validating the resulting XHTML pages" ; \
- $(XMLLINT) --nonet --valid --noout html/*.html ; \
+ SGML_CATALOG_FILES=$(XML_CATALOG_FILE) \
+ $(XMLLINT) --catalogs --nonet --valid --noout html/*.html ; \
else echo "missing XHTML1 DTD" ; fi ; fi
$(addprefix $(srcdir)/,$(devhelphtml)): $(srcdir)/libvirt-api.xml $(devhelpxsl)
--
1.7.3
14 years, 1 month
[libvirt] [PATCH] docs: install the generated html files when make install is run
by Justin Clift
Previously, only the API docs were installed, rather than the
complete documentation set. This commit ensures the complete
documentation set is installed.
---
docs/Makefile.am | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/docs/Makefile.am b/docs/Makefile.am
index 27804a2..f1ec2a6 100644
--- a/docs/Makefile.am
+++ b/docs/Makefile.am
@@ -26,6 +26,11 @@ devhelphtml = \
devhelp/libvirt-libvirt.html \
devhelp/libvirt-virterror.html
+css = \
+ generic.css \
+ libvirt.css \
+ main.css
+
devhelppng = \
devhelp/home.png \
devhelp/left.png \
@@ -169,6 +174,10 @@ rebuild: api all
install-data-local:
$(mkinstalldirs) $(DESTDIR)$(HTML_DIR)
+ for f in $(css) $(dot_html); do \
+ $(INSTALL) -m 0644 $(srcdir)/$$f $(DESTDIR)$(HTML_DIR); done
+ for f in $(gif) $(png); do \
+ $(INSTALL) -m 0644 $(srcdir)/$$f $(DESTDIR)$(HTML_DIR); done
-$(INSTALL) -m 0644 $(srcdir)/Libxml2-Logo-90x34.gif $(DESTDIR)$(HTML_DIR)
$(mkinstalldirs) $(DESTDIR)$(HTML_DIR)/html
for h in $(apihtml); do \
--
1.7.2.3
14 years, 1 month
Re: [libvirt] How to start a defined domain
by Osier
----- "黄亮" <lancerhuang(a)163.com> wrote:
>
> Well, after "make clean", I run the compiled start.c, still won't
> work.
"make clean" won't uninstall the installed stuffs, use "make uninstall"
instead, or you just made a typo? :-)
after that, suggest re-installing 0.6.3 if you are not sure if it's injured.
- Osier
> And I forget to metion, an error msg is shown:
>
> libvir: Xen error : Domain not found: xenUnifiedDomainLookupByName
>
> is that means I missed something?
>
>
> 2010-10-26
>
> 黄亮
>
> 发件人: Osier
> 发送时间: 2010-10-26 18:05:46
> 收件人: 黄亮
> 抄送:
> 主题: Re: [libvirt] How to start a defined domain
>
>
>
> ----- "黄亮" <lancerhuang(a)163.com> wrote:
>
> >
> > Accroding to your case, it seems I have no need to upgrade libvirt
> to
> > 0.8.4
> > Will that work if I erase 0.8.4 using "make clean" and draw back to
> > 0.6.3 ?
>
> yep, think so, if you don't need the new features, and 0.6.3 is enough
> for your project requirement.. :-)
>
> - Osier
> >
> >
> >
> > 2010-10-26
> >
> > 黄亮
> >
> > 发件人: Osier
> > 发送时间: 2010-10-26 17:10:40
> > 收件人: 黄亮
> > 抄送:
> > 主题: Re: [libvirt] How to start a defined domain
> >
> >
> >
> > ----- "黄亮" <lancerhuang(a)163.com> wrote:
> >
> > >
> > > Thanks for your reply, Osier.
> > >
> > >
> > > The distro I'm using is CentOS release 5.5 (Final)
> > >
> > > I'm not quite sure about the version of libvirt. At first, it
> seems
> > to
> > > be 0.6.3, because /usr/lib64/libvirt.so.0 points to
> > > /usr/lib64/libvirt.so.0.6.3
> > > Then I downloaded the src of libvirt_0.8.4 from offical website,
> and
> > > configure, make, make install.
> > > But now it show errors when I type "virsh". The error message lies
> > > below:
> > >
> > > virsh: /usr/local/lib/libvirt.so.0: version `LIBVIRT_0.8.2' not
> > found
> > > (required by virsh)
> > > virsh: /usr/local/lib/libvirt.so.0: version `LIBVIRT_0.7.1' not
> > found
> > > (required by virsh)
> > > virsh: /usr/local/lib/libvirt.so.0: version `LIBVIRT_0.7.5' not
> > found
> > > (required by virsh)
> > > virsh: /usr/local/lib/libvirt.so.0: version `LIBVIRT_0.8.1' not
> > found
> > > (required by virsh)
> > > virsh: /usr/local/lib/libvirt.so.0: version `LIBVIRT_0.7.0' not
> > found
> > > (required by virsh)
> > > virsh: /usr/local/lib/libvirt.so.0: version `LIBVIRT_0.7.2' not
> > found
> > > (required by virsh)
> > > virsh: /usr/local/lib/libvirt.so.0: version `LIBVIRT_0.7.3' not
> > found
> > > (required by virsh)
> > > virsh: /usr/local/lib/libvirt.so.0: version `LIBVIRT_0.8.0' not
> > found
> > > (required by virsh)
> > > virsh: /usr/local/lib/libvirt.so.0: version
> `LIBVIRT_PRIVATE_0.8.4'
> > > not found (required by virsh)
> > > virsh: /usr/local/lib/libvirt.so.0: version `LIBVIRT_0.7.7' not
> > found
> > > (required by virsh)
> > > virsh: /usr/local/lib/libvirt.so.0: version `LIBVIRT_0.6.4' not
> > found
> > > (required by virsh)
> >
> > probly you should try to erase the 0.6.3, then compile and install
> > libvirt
> > like:
> >
> > # ./configure --prefix=/usr --libdir=/usr/lib64
> > # make
> > # make install
> >
> > your test program has no problem on my box. the libvirt on my box
> also
> > is
> > 0.6.3.
> >
> > Regards
> >
> > - Osier
> > >
> > > As for xen, it is 3.3.2. The full "xm info" message is listed
> below:
> > > host : testbed01
> > > release : 2.6.18-194.11.4.el5xen
> > > version : #1 SMP Tue Sep 21 05:40:24 EDT 2010
> > > machine : x86_64
> > > nr_cpus : 8
> > > nr_nodes : 1
> > > cores_per_socket : 4
> > > threads_per_core : 2
> > > cpu_mhz : 2793
> > > hw_caps :
> > >
> >
> bfebfbff:28100800:00000000:00000140:0098e3fd:00000000:00000001:00000000
> > > virt_caps : hvm
> > > total_memory : 4055
> > > free_memory : 533
> > > node_to_cpu : node0:0-7
> > > node_to_memory : node0:533
> > > xen_major : 3
> > > xen_minor : 3
> > > xen_extra : .2
> > > xen_caps : xen-3.0-x86_64 xen-3.0-x86_32p hvm-3.0-x86_32
> > > hvm-3.0-x86_32p hvm-3.0-x86_64
> > > xen_scheduler : credit
> > > xen_pagesize : 4096
> > > platform_params : virt_start=0xffff800000000000
> > > xen_changeset : unavailable
> > > cc_compiler : gcc version 4.1.2 20080704 (Red Hat 4.1.2-44)
> > > cc_compile_by : root
> > > cc_compile_domain : gitco.tld
> > > cc_compile_date : Tue Aug 18 21:07:28 CEST 2009
> > > xend_config_format : 4
> > >
> > > I've write a simple c program to test the api, and it is listed
> > below:
> > >
> > > 1 // This program aims to test the api which can start the VM
> > > 2
> > > 3 #include "stdio.h"
> > > 4 #include "stdlib.h"
> > > 5 #include "libvirt/libvirt.h"
> > > 6
> > > 7 int main(int argc ,char* argv[])
> > > 8 {
> > > 9 virConnectPtr conn;
> > > 10 conn = virConnectOpen( "xen+tcp://localhost?no_Verify=1" );
> > > 11 if( conn == NULL )
> > > 12 {
> > > 13 printf( "Failed to Connect\n" );
> > > 14 return 1;
> > > 15 }
> > > 16 const char* host = "vm01";
> > > 17 virDomainPtr dom;
> > > 18 dom = virDomainLookupByName( conn, host );
> > > 19 if( dom == NULL )
> > > 20 {
> > > 21 printf( "can't find dom\n" );
> > > 22 return 1;
> > > 23 }
> > > 24 // else
> > > 25 // {
> > > 26 // virDomainFree( dom );
> > > 27 // virConnectClose( conn );
> > > 28 // printf("done\n");
> > > 29 // return 0;
> > > 30 // }
> > > 31 if( virDomainCreate( dom ) == -1 )
> > > 32 {
> > > 33 printf( "failed to Start\n" );
> > > 34 virDomainFree( dom );
> > > 35 virConnectClose( conn );
> > > 36 return 1;
> > > 37 }
> > > 38 else
> > > 39 {
> > > 40 printf( "Started\n" );
> > > 41 virDomainFree( dom );
> > > 42 virConnectClose( conn );
> > > 43 return 0;
> > > 44 }
> > > 45 }
> > >
> > > 2010-10-26
> > >
> > > Lancer
> > >
> > > 发件人: Osier
> > > 发送时间: 2010-10-26 11:35:31
> > > 收件人: 黄亮
> > > 抄送: libvir-list
> > > 主题: Re: [libvirt] How to start a defined domain
> > >
> > >
> > >
> > > ----- "黄亮" <lancerhuang(a)163.com> wrote:
> > >
> > > > I've create a domain called "vm01" using Virt-Manager, the GUI
> > tool.
> > > > Now I wanna use libvirt api to control the life cycle of vm01.
> > > > It went on well with shutdown and reboot, but how to start it
> > became
> > > a
> > > > problem.
> > > >
> > > > I was intended to get the virDomainPtr by using
> > > virDomainLookupByName
> > > > api, and then start it using virDomainCreate api.
> > > > But it turns out that virDomainLookupByName api cannot return a
> > > > virDomainPtr for a defined but not running domain.
> > > >
> > >
> > > no, it can :-)
> > >
> > > If it really doesn't work for you, could you write a simple
> program
> > to
> > > reproduce it? and try to explain what's the version of libvirt you
> > > use,
> > > on which distro, etc, any helpful info is welcomed. :-)
> > >
> > > Thanks
> > >
> > > - Osier
> > >
> > > > That's my situation, what do you suggest I do now?
> > > > Thanks in advance.
> > > >
> > > > 2010-10-26
> > > >
> > > > Lancer
> > > > --
> > > > libvir-list mailing list
> > > > libvir-list(a)redhat.com
> > > > https://www.redhat.com/mailman/listinfo/libvir-list
> > >
> > > __________ Information from ESET Smart Security, version of virus
> > > signature database 5562 (20101025) __________
> > >
> > > The message was checked by ESET Smart Security.
> > >
> > > http://www.eset.com
> >
> > __________ Information from ESET Smart Security, version of virus
> > signature database 5562 (20101025) __________
> >
> > The message was checked by ESET Smart Security.
> >
> > http://www.eset.com
>
> __________ Information from ESET Smart Security, version of virus
> signature database 5563 (20101026) __________
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
14 years, 1 month
[libvirt] [PATCH] Fix build for SystemTap 1.0
by Matthias Bolte
With SystemTap 1.0 a part of the generated macros in probes.h
expands to:
volatile __typeof__(((name))) arg2 = (name);
GCC reports an 'invalid initialize' error when name has type
char[]. Therfore, add casts to char* to avoid this.
---
daemon/libvirtd.c | 4 ++--
daemon/remote.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 8e88d05..d3f003e 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -1230,11 +1230,11 @@ remoteCheckCertificate(struct qemud_client *client)
}
}
- PROBE(CLIENT_TLS_ALLOW, "fd=%d, name=%s", client->fd, name);
+ PROBE(CLIENT_TLS_ALLOW, "fd=%d, name=%s", client->fd, (char *)name);
return 0;
authdeny:
- PROBE(CLIENT_TLS_DENY, "fd=%d, name=%s", client->fd, name);
+ PROBE(CLIENT_TLS_DENY, "fd=%d, name=%s", client->fd, (char *)name);
return -1;
authfail:
diff --git a/daemon/remote.c b/daemon/remote.c
index 3b72f98..50ccb3b 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -4223,7 +4223,7 @@ remoteDispatchAuthPolkit (struct qemud_server *server,
goto authdeny;
}
PROBE(CLIENT_AUTH_ALLOW, "fd=%d, auth=%d, username=%s",
- client->fd, REMOTE_AUTH_POLKIT, ident);
+ client->fd, REMOTE_AUTH_POLKIT, (char *)ident);
VIR_INFO(_("Policy allowed action %s from pid %d, uid %d"),
action, callerPid, callerUid);
ret->complete = 1;
@@ -4238,7 +4238,7 @@ authfail:
authdeny:
PROBE(CLIENT_AUTH_DENY, "fd=%d, auth=%d, username=%s",
- client->fd, REMOTE_AUTH_POLKIT, ident);
+ client->fd, REMOTE_AUTH_POLKIT, (char *)ident);
goto error;
error:
--
1.7.0.4
14 years, 1 month
[libvirt] [PATCH] xen: Fix domain dump
by Jiri Denemark
Remove redundant 'live' parameter which caused an error from xend:
"xend.err 'Too many values for live'"
---
src/xen/xend_internal.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index b90c331..bce911e 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -3026,7 +3026,7 @@ xenDaemonDomainCoreDump(virDomainPtr domain, const char *filename,
}
return xend_op(domain->conn, domain->name,
- "op", "dump", "file", filename, "live", "0",
+ "op", "dump", "file", filename,
"live", (flags & VIR_DUMP_LIVE ? "1" : "0"),
"crash", (flags & VIR_DUMP_CRASH ? "1" : "0"),
NULL);
--
1.7.3.2
14 years, 1 month
[libvirt] [PATCH] Avoid squashing errors during network startup cleanup path
by Daniel P. Berrange
When failing to start a virtual network, we have to cleanup,
tearing down any iptables rules. If the iptables rules were
not present yet though, this raises an error, which squashes
the original error we were handling.
* src/network/bridge_driver.c: When failing to start a virtual
network, don't squash the original error in cleanup
---
src/network/bridge_driver.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 8721747..0777d85 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -1171,6 +1171,7 @@ static int networkStartNetworkDaemon(struct network_driver *driver,
virNetworkObjPtr network)
{
int err;
+ virErrorPtr save_err;
if (virNetworkObjIsActive(network)) {
networkReportError(VIR_ERR_INTERNAL_ERROR,
@@ -1255,7 +1256,12 @@ static int networkStartNetworkDaemon(struct network_driver *driver,
}
err_delbr2:
+ save_err = virSaveLastError();
networkRemoveIptablesRules(driver, network);
+ if (save_err) {
+ virSetError(save_err);
+ virFreeError(save_err);
+ }
err_delbr1:
if ((err = brSetInterfaceUp(driver->brctl, network->def->bridge, 0))) {
--
1.7.2.3
14 years, 1 month