[libvirt] [PATCH] tests: add forgotten boot-strict test files
by Laine Stump
These *should* have been pushed in commit
96fddee322c7d39a57cfdc5e7be71326d597d30a.
---
Pushed under the build-breaker rule :-(
.../qemuxml2argvdata/qemuxml2argv-boot-strict.args | 36 ++++++++++++
.../qemuxml2argvdata/qemuxml2argv-boot-strict.xml | 66 ++++++++++++++++++++++
2 files changed, 102 insertions(+)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-boot-strict.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-boot-strict.xml
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-boot-strict.args b/tests/qemuxml2argvdata/qemuxml2argv-boot-strict.args
new file mode 100644
index 0000000..19e1217
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-boot-strict.args
@@ -0,0 +1,36 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu \
+-S \
+-M pc \
+-m 214 \
+-smp 1 \
+-nographic \
+-nodefaults \
+-monitor unix:/tmp/test-monitor,server,nowait \
+-no-acpi \
+-boot strict=on \
+-usb \
+-drive file=/tmp/vda.img,if=none,id=drive-virtio-disk0 \
+-device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x5,drive=drive-virtio-disk0,\
+id=virtio-disk0,bootindex=3 \
+-drive file=/tmp/vdb.img,if=none,id=drive-virtio-disk1 \
+-device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x6,drive=drive-virtio-disk1,\
+id=virtio-disk1 \
+-drive file=/dev/HostVG/hda,if=none,id=drive-ide0-0-0 \
+-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
+-drive file=/dev/HostVG/hdb,if=none,id=drive-ide0-0-1 \
+-device ide-drive,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1 \
+-drive file=/dev/HostVG/hdc,if=none,media=cdrom,id=drive-ide0-1-0 \
+-device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0,\
+bootindex=1 \
+-drive file=/dev/fd0,if=none,id=drive-fdc0-0-0 \
+-global isa-fdc.driveA=drive-fdc0-0-0 \
+-global isa-fdc.bootindexA=4 \
+-drive file=/dev/fd1,if=none,id=drive-fdc0-0-1 \
+-global isa-fdc.driveB=drive-fdc0-0-1 \
+-device virtio-net-pci,vlan=0,id=net0,mac=00:11:22:33:44:11,bus=pci.0,\
+addr=0x3,bootindex=2 \
+-net user,vlan=0,name=hostnet0 \
+-device virtio-net-pci,vlan=1,id=net1,mac=00:11:22:33:44:22,bus=pci.0,\
+addr=0x4 \
+-net user,vlan=1,name=hostnet1
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-boot-strict.xml b/tests/qemuxml2argvdata/qemuxml2argv-boot-strict.xml
new file mode 100644
index 0000000..b20013b
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-boot-strict.xml
@@ -0,0 +1,66 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='cdrom'/>
+ <boot dev='network'/>
+ <boot dev='hd'/>
+ <boot dev='fd'/>
+ </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='file' device='disk'>
+ <source file='/tmp/vdb.img'/>
+ <target dev='vdb' bus='virtio'/>
+ </disk>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/hdb'/>
+ <target dev='hdb' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='1'/>
+ </disk>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/hda'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <disk type='file' device='disk'>
+ <source file='/tmp/vda.img'/>
+ <target dev='vda' bus='virtio'/>
+ </disk>
+ <disk type='block' device='cdrom'>
+ <source dev='/dev/HostVG/hdc'/>
+ <target dev='hdc' bus='ide'/>
+ <address type='drive' controller='0' bus='1' target='0' unit='0'/>
+ </disk>
+ <disk type='block' device='floppy'>
+ <source dev='/dev/fd1'/>
+ <target dev='fdb' bus='fdc'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='1'/>
+ </disk>
+ <disk type='block' device='floppy'>
+ <source dev='/dev/fd0'/>
+ <target dev='fda' bus='fdc'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'/>
+ <controller type='fdc' index='0'/>
+ <controller type='ide' index='0'/>
+ <interface type='user'>
+ <mac address='00:11:22:33:44:11'/>
+ <model type='virtio'/>
+ </interface>
+ <interface type='user'>
+ <mac address='00:11:22:33:44:22'/>
+ <model type='virtio'/>
+ </interface>
+ <memballoon model='none'/>
+ </devices>
+</domain>
--
1.8.4.2
10 years, 11 months
[libvirt] [PATCHv3] qemu: Refactor qemuTranslateDiskSourcePool
by Peter Krempa
Before this patch, the translation function still needs a second ugly
helper function to actually format the command line for qemu. But if we
do the right stuff in the translation function, we don't have to bother
with the second function any more.
This patch removes the messy qemuBuildVolumeString function and changes
qemuTranslateDiskSourcePool to set stuff up correctly so that the
regular code paths meant for volumes can be used to format the command
line correctly.
For this purpose a new helper "qemuDiskGetActualType()" is introduced to
return the type of the volume in a pool.
As a part of the refactor the qemuTranslateDiskSourcePool function is
fixed to do decisions based on the pool type instead of the volume type.
This allows to separate pool-type-specific stuff more clearly and will
ease addition of other pool types that will require certain other
operations to get the correct pool source.
The previously fixed tests should make sure that we don't break stuff
that was working before.
---
Notes:
Version 3:
- fixed commit message typos
- the tray status error message now states if it's a disk or a volume
- returned startup policy checking
Version 2:
- Fixed accidental squash into the previous commit
src/conf/domain_conf.h | 1 +
src/libvirt_private.syms | 1 +
src/qemu/qemu_command.c | 81 ++++------------------------
src/qemu/qemu_conf.c | 136 ++++++++++++++++++++++++++++++++++-------------
src/qemu/qemu_conf.h | 2 +
5 files changed, 112 insertions(+), 109 deletions(-)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 5afbfa7..4934911 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -686,6 +686,7 @@ struct _virDomainDiskSourcePoolDef {
char *volume; /* volume name */
int voltype; /* enum virStorageVolType, internal only */
int pooltype; /* enum virStoragePoolType, internal only */
+ int actualtype; /* enum virDomainDiskType, internal only */
int mode; /* enum virDomainDiskSourcePoolMode */
};
typedef virDomainDiskSourcePoolDef *virDomainDiskSourcePoolDefPtr;
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 3a8cbe5..b2c7a8e 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -696,6 +696,7 @@ virStoragePoolSourceFree;
virStoragePoolSourceListFormat;
virStoragePoolSourceListNewSource;
virStoragePoolTypeFromString;
+virStoragePoolTypeToString;
virStorageVolDefFindByKey;
virStorageVolDefFindByName;
virStorageVolDefFindByPath;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 763417f..d5c9c09 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3775,69 +3775,6 @@ qemuBuildNBDString(virConnectPtr conn, virDomainDiskDefPtr disk, virBufferPtr op
return 0;
}
-static int
-qemuBuildVolumeString(virConnectPtr conn,
- virDomainDiskDefPtr disk,
- virBufferPtr opt)
-{
- int ret = -1;
-
- switch ((virStorageVolType) disk->srcpool->voltype) {
- case VIR_STORAGE_VOL_DIR:
- if (!disk->readonly) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("cannot create virtual FAT disks in read-write mode"));
- goto cleanup;
- }
- if (disk->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY)
- virBufferEscape(opt, ',', ",", "file=fat:floppy:%s,", disk->src);
- else
- virBufferEscape(opt, ',', ",", "file=fat:%s,", disk->src);
- break;
- case VIR_STORAGE_VOL_BLOCK:
- if (disk->tray_status == VIR_DOMAIN_DISK_TRAY_OPEN) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("tray status 'open' is invalid for "
- "block type volume"));
- goto cleanup;
- }
- if (disk->srcpool->pooltype == VIR_STORAGE_POOL_ISCSI) {
- if (disk->srcpool->mode ==
- VIR_DOMAIN_DISK_SOURCE_POOL_MODE_DIRECT) {
- if (qemuBuildISCSIString(conn, disk, opt) < 0)
- goto cleanup;
- virBufferAddChar(opt, ',');
- } else if (disk->srcpool->mode ==
- VIR_DOMAIN_DISK_SOURCE_POOL_MODE_HOST) {
- virBufferEscape(opt, ',', ",", "file=%s,", disk->src);
- }
- } else {
- virBufferEscape(opt, ',', ",", "file=%s,", disk->src);
- }
- break;
- case VIR_STORAGE_VOL_FILE:
- if (disk->auth.username) {
- if (qemuBuildISCSIString(conn, disk, opt) < 0)
- goto cleanup;
- virBufferAddChar(opt, ',');
- } else {
- virBufferEscape(opt, ',', ",", "file=%s,", disk->src);
- }
- break;
- case VIR_STORAGE_VOL_NETWORK:
- case VIR_STORAGE_VOL_NETDIR:
- case VIR_STORAGE_VOL_LAST:
- /* Keep the compiler quiet, qemuTranslateDiskSourcePool already
- * reported the unsupported error.
- */
- goto cleanup;
- }
-
- ret = 0;
-
-cleanup:
- return ret;
-}
char *
qemuBuildDriveStr(virConnectPtr conn ATTRIBUTE_UNUSED,
@@ -3851,6 +3788,7 @@ qemuBuildDriveStr(virConnectPtr conn ATTRIBUTE_UNUSED,
virDomainDiskGeometryTransTypeToString(disk->geometry.trans);
int idx = virDiskNameToIndex(disk->dst);
int busid = -1, unitid = -1;
+ int actualType = qemuDiskGetActualType(disk);
if (idx < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -3934,12 +3872,13 @@ qemuBuildDriveStr(virConnectPtr conn ATTRIBUTE_UNUSED,
/* disk->src is NULL when we use nbd disks */
if ((disk->src ||
- (disk->type == VIR_DOMAIN_DISK_TYPE_NETWORK &&
+ (actualType == VIR_DOMAIN_DISK_TYPE_NETWORK &&
disk->protocol == VIR_DOMAIN_DISK_PROTOCOL_NBD)) &&
!((disk->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY ||
disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) &&
disk->tray_status == VIR_DOMAIN_DISK_TRAY_OPEN)) {
- if (disk->type == VIR_DOMAIN_DISK_TYPE_DIR) {
+
+ if (actualType == VIR_DOMAIN_DISK_TYPE_DIR) {
/* QEMU only supports magic FAT format for now */
if (disk->format > 0 && disk->format != VIR_STORAGE_FILE_FAT) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -3957,7 +3896,7 @@ qemuBuildDriveStr(virConnectPtr conn ATTRIBUTE_UNUSED,
disk->src);
else
virBufferEscape(&opt, ',', ",", "file=fat:%s,", disk->src);
- } else if (disk->type == VIR_DOMAIN_DISK_TYPE_NETWORK) {
+ } else if (actualType == VIR_DOMAIN_DISK_TYPE_NETWORK) {
switch (disk->protocol) {
case VIR_DOMAIN_DISK_PROTOCOL_NBD:
if (qemuBuildNBDString(conn, disk, &opt) < 0)
@@ -4025,15 +3964,13 @@ qemuBuildDriveStr(virConnectPtr conn ATTRIBUTE_UNUSED,
virBufferEscape(&opt, ',', ",", "%s,", disk->src);
break;
}
- } else if (disk->type == VIR_DOMAIN_DISK_TYPE_VOLUME) {
- if (qemuBuildVolumeString(conn, disk, &opt) < 0)
- goto error;
} else {
- if ((disk->type == VIR_DOMAIN_DISK_TYPE_BLOCK) &&
+ if ((actualType == VIR_DOMAIN_DISK_TYPE_BLOCK) &&
(disk->tray_status == VIR_DOMAIN_DISK_TRAY_OPEN)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("tray status 'open' is invalid for "
- "block type disk"));
+ "block type %s"),
+ disk->type == VIR_DOMAIN_DISK_TYPE_VOLUME ? _("volume") : _("disk"));
goto error;
}
virBufferEscape(&opt, ',', ",", "file=%s,", disk->src);
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 557ccc5..36493ba 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1298,6 +1298,17 @@ cleanup:
return ret;
}
+
+int
+qemuDiskGetActualType(virDomainDiskDefPtr def)
+{
+ if (def->type == VIR_DOMAIN_DISK_TYPE_VOLUME)
+ return def->srcpool->actualtype;
+
+ return def->type;
+}
+
+
int
qemuTranslateDiskSourcePool(virConnectPtr conn,
virDomainDiskDefPtr def)
@@ -1319,72 +1330,123 @@ qemuTranslateDiskSourcePool(virConnectPtr conn,
if (!(pool = virStoragePoolLookupByName(conn, def->srcpool->pool)))
return -1;
+ if (virStoragePoolIsActive(pool) != 1) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("storage pool '%s' containing volume '%s' "
+ "is not active"),
+ def->srcpool->pool, def->srcpool->volume);
+ goto cleanup;
+ }
+
if (!(vol = virStorageVolLookupByName(pool, def->srcpool->volume)))
goto cleanup;
if (virStorageVolGetInfo(vol, &info) < 0)
goto cleanup;
- if (def->startupPolicy &&
- info.type != VIR_STORAGE_VOL_FILE) {
+ if (!(poolxml = virStoragePoolGetXMLDesc(pool, 0)))
+ goto cleanup;
+
+ if (!(pooldef = virStoragePoolDefParseString(poolxml)))
+ goto cleanup;
+
+ def->srcpool->pooltype = pooldef->type;
+ def->srcpool->voltype = info.type;
+
+ if (def->srcpool->mode && pooldef->type != VIR_STORAGE_POOL_ISCSI) {
virReportError(VIR_ERR_XML_ERROR, "%s",
- _("'startupPolicy' is only valid for 'file' type volume"));
+ _("disk source mode is only valid when "
+ "storage pool is of iscsi type"));
goto cleanup;
}
- switch ((virStorageVolType) info.type) {
- case VIR_STORAGE_VOL_FILE:
- case VIR_STORAGE_VOL_DIR:
+ switch ((enum virStoragePoolType) pooldef->type) {
+ case VIR_STORAGE_POOL_DIR:
+ case VIR_STORAGE_POOL_FS:
+ case VIR_STORAGE_POOL_NETFS:
+ case VIR_STORAGE_POOL_LOGICAL:
+ case VIR_STORAGE_POOL_DISK:
+ case VIR_STORAGE_POOL_SCSI:
if (!(def->src = virStorageVolGetPath(vol)))
goto cleanup;
- break;
- case VIR_STORAGE_VOL_BLOCK:
- if (!(poolxml = virStoragePoolGetXMLDesc(pool, 0)))
+
+ if (def->startupPolicy && info.type != VIR_STORAGE_VOL_FILE) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("'startupPolicy' is only valid for "
+ "'file' type volume"));
goto cleanup;
+ }
+
+
+ switch (info.type) {
+ case VIR_STORAGE_VOL_FILE:
+ def->srcpool->actualtype = VIR_DOMAIN_DISK_TYPE_FILE;
+ break;
+
+ case VIR_STORAGE_VOL_DIR:
+ def->srcpool->actualtype = VIR_DOMAIN_DISK_TYPE_DIR;
+ break;
+
+ case VIR_STORAGE_VOL_BLOCK:
+ def->srcpool->actualtype = VIR_DOMAIN_DISK_TYPE_BLOCK;
+ break;
- if (!(pooldef = virStoragePoolDefParseString(poolxml)))
+ case VIR_STORAGE_VOL_NETWORK:
+ case VIR_STORAGE_VOL_NETDIR:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unexpected storage volume type '%s' "
+ "for storage pool type '%s'"),
+ virStorageVolTypeToString(info.type),
+ virStoragePoolTypeToString(pooldef->type));
goto cleanup;
+ }
+
+ break;
- if (def->srcpool->mode && pooldef->type != VIR_STORAGE_POOL_ISCSI) {
+ case VIR_STORAGE_POOL_ISCSI:
+ if (def->startupPolicy) {
virReportError(VIR_ERR_XML_ERROR, "%s",
- _("disk source mode is only valid when "
- "storage pool is of iscsi type"));
+ _("'startupPolicy' is only valid for "
+ "'file' type volume"));
goto cleanup;
}
- def->srcpool->pooltype = pooldef->type;
- if (pooldef->type == VIR_STORAGE_POOL_ISCSI) {
- /* Default to use the LUN's path on host */
- if (!def->srcpool->mode)
- def->srcpool->mode = VIR_DOMAIN_DISK_SOURCE_POOL_MODE_HOST;
-
- if (def->srcpool->mode ==
- VIR_DOMAIN_DISK_SOURCE_POOL_MODE_DIRECT) {
- if (qemuAddISCSIPoolSourceHost(def, pooldef) < 0)
- goto cleanup;
- } else if (def->srcpool->mode ==
- VIR_DOMAIN_DISK_SOURCE_POOL_MODE_HOST) {
- if (!(def->src = virStorageVolGetPath(vol)))
- goto cleanup;
- }
+ switch (def->srcpool->mode) {
+ case VIR_DOMAIN_DISK_SOURCE_POOL_MODE_DEFAULT:
+ case VIR_DOMAIN_DISK_SOURCE_POOL_MODE_LAST:
+ def->srcpool->mode = VIR_DOMAIN_DISK_SOURCE_POOL_MODE_HOST;
+ /* fallthrough */
+ case VIR_DOMAIN_DISK_SOURCE_POOL_MODE_HOST:
+ def->srcpool->actualtype = VIR_DOMAIN_DISK_TYPE_BLOCK;
+ if (!(def->src = virStorageVolGetPath(vol)))
+ goto cleanup;
+ break;
+
+ case VIR_DOMAIN_DISK_SOURCE_POOL_MODE_DIRECT:
+ def->srcpool->actualtype = VIR_DOMAIN_DISK_TYPE_NETWORK;
+ def->protocol = VIR_DOMAIN_DISK_PROTOCOL_ISCSI;
if (qemuTranslateDiskSourcePoolAuth(def, pooldef) < 0)
goto cleanup;
- } else {
- if (!(def->src = virStorageVolGetPath(vol)))
+
+ if (qemuAddISCSIPoolSourceHost(def, pooldef) < 0)
goto cleanup;
+ break;
}
-
break;
- case VIR_STORAGE_VOL_NETWORK:
- case VIR_STORAGE_VOL_NETDIR:
- case VIR_STORAGE_VOL_LAST:
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("Using network volume as disk source is not supported"));
+
+ case VIR_STORAGE_POOL_MPATH:
+ case VIR_STORAGE_POOL_RBD:
+ case VIR_STORAGE_POOL_SHEEPDOG:
+ case VIR_STORAGE_POOL_GLUSTER:
+ case VIR_STORAGE_POOL_LAST:
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("using '%s' pools for backing 'volume' disks "
+ "isn't yet supported"),
+ virStoragePoolTypeToString(pooldef->type));
goto cleanup;
}
- def->srcpool->voltype = info.type;
ret = 0;
cleanup:
if (ret < 0)
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index d1ae415..0cb7901 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -305,6 +305,8 @@ int qemuSetUnprivSGIO(virDomainDeviceDefPtr dev);
int qemuDriverAllocateID(virQEMUDriverPtr driver);
virDomainXMLOptionPtr virQEMUDriverCreateXMLConf(virQEMUDriverPtr driver);
+int qemuDiskGetActualType(virDomainDiskDefPtr def);
+
int qemuTranslateDiskSourcePool(virConnectPtr conn,
virDomainDiskDefPtr def);
--
1.8.4.3
10 years, 11 months
[libvirt] [PATCHv2 0/3] Rebase of patch to add support for RBD storage pools
by Adam Walters
This series of patches adds support for RBD storage pools to the latest version
of libvirt. Included in this is a simple structure to build additional network
storage pool support off of (really a couple of if/else blocks, so nothing
fancy).
This code passes check, check-syntax, and the valgrind tests. Additionally, the
code is tested working in my environment. In fact, the machine I am sending this
email from is a VM being run under qemu+libvirt with backend storage being an RBD
storage pool using this code. Unfortunately, I only have the one RBD pool and
libvirt host, so the code could use additional testing.
If anyone finds any problems with my code, please let me know. I will fix them and
resubmit the patch as needed. Hopefully someone else out there finds this support
as useful as I do. While not many libvirt management clients utilize the storage
API today, it does look to be the better method to interact with storage, and thus
likely to be the best way to go in the future. I figure that additional storage
backend support may well help to get others using the API instead of duplicating
configuration options across every VM.
Adam Walters (3):
qemu: config: Add qemuAddRBDPoolSourceHost helper function
qemu: conf: Parse RBD storage pool from domain xml
qemu: command: Handle RBD storage pools
src/qemu/qemu_command.c | 11 +++++++++
src/qemu/qemu_conf.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 76 insertions(+)
--
1.8.4.2
10 years, 11 months
[libvirt] [PATCH] Doc: Explicitly declaring that nodedev-destroy only works for vHBA
by Osier Yang
Though trying to destroy a physical HBA doesn't make sense at all,
it's still a bit misleading with saying "only works for HBA".
Signed-off-by: Osier Yang <jyang(a)redhat.com>
---
src/libvirt.c | 5 +++--
tools/virsh.pod | 6 +++---
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c
index ae05300..4ebd13f 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -16065,8 +16065,9 @@ error:
* virNodeDeviceDestroy:
* @dev: a device object
*
- * Destroy the device object. The virtual device is removed from the host operating system.
- * This function may require privileged access
+ * Destroy the device object. The virtual device (only works for vHBA
+ * currently) is removed from the host operating system. This function
+ * may require privileged access.
*
* Returns 0 in case of success and -1 in case of failure.
*/
diff --git a/tools/virsh.pod b/tools/virsh.pod
index dac9a08..557df9c 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -2158,9 +2158,9 @@ contains xml for a top-level <device> description of a node device.
=item B<nodedev-destroy> I<device>
Destroy (stop) a device on the host. I<device> can be either device
-name or wwn pair in "wwnn,wwpn" format (only works for HBA). Note
-that this makes libvirt quit managing a host device, and may even make
-that device unusable by the rest of the physical host until a reboot.
+name or wwn pair in "wwnn,wwpn" format (only works for vHBA currently).
+Note that this makes libvirt quit managing a host device, and may even
+make that device unusable by the rest of the physical host until a reboot.
=item B<nodedev-detach> I<nodedev> [I<--driver backend_driver>]
--
1.8.1.4
10 years, 11 months
[libvirt] [question] We can create two network of one same linux bridge or local ethernet. It is a bug?
by Sheldon
> We can create two network of one same linux bridge or local ethernet:
This is not harmful.
But I wonder should this case is allowed? Why?
more detail as follow.
>
> virsh # net-list --all
> Name State Autostart Persistent
> ----------------------------------------------------------
> br1 active yes yes
> br2 active yes yes
> default active yes yes
>
> virsh # net-dumpxml br1
> <network>
> <name>br1</name>
> <uuid>d5410814-1bea-b10d-04b8-9fbd3a1cfc65</uuid>
> <forward mode='bridge'/>
> <bridge name='br0' />
> </network>
>
> virsh # net-dumpxml br2
> <network>
> <name>br2</name>
> <uuid>99f20705-57cd-da31-f193-d13af4158792</uuid>
> <forward mode='bridge'/>
> <bridge name='br0' />
> </network>
>
> virsh # net-list --all
> Name State Autostart Persistent
> ----------------------------------------------------------
> br0 active yes yes
> br1 active yes yes
> default active yes yes
>
> virsh # net-dumpxml br0
> <network>
> <name>br0</name>
> <uuid>a35c840a-9bdc-070d-43f5-8e834040aa42</uuid>
> <forward dev='eth0' mode='bridge'>
> <interface dev='eth0'/>
> </forward>
> </network>
>
> virsh # net-dumpxml br1
> <network>
> <name>br1</name>
> <uuid>f1c87b80-2dfc-2a71-3fb6-56ef83daf29a</uuid>
> <forward dev='eth0' mode='bridge'>
> <interface dev='eth0'/>
> </forward>
> </network>
--
Sheldon Feng(冯少合)<shaohef(a)linux.vnet.ibm.com>
IBM Linux Technology Center
10 years, 11 months
[libvirt] [PATCH] qemu: fix lastError memory leak
by Wangyufei (James)
When an error occurred in qemuMonitorIO, it will be saved in mon->lastError,
but the memory which mon->lastError.message, mon->lastError.str1,
mon->lastError.str2 and mon->lastError.str3 will not be freed at last.
The same bug happened in qemuAgentIO. So I add the following code to fix it.
Signed-off-by: Zhou Yimin <zhouyimin(a)huawei.com>
---
src/qemu/qemu_agent.c | 2 ++
src/qemu/qemu_monitor.c | 2 ++
2 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 2cd0ccc..475b43e 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -161,6 +161,8 @@ static void qemuAgentDispose(void *obj)
(mon->cb->destroy)(mon, mon->vm);
virCondDestroy(&mon->notify);
VIR_FREE(mon->buffer);
+ if (mon->lastError.code != VIR_ERR_OK)
+ virResetError(&mon->lastError);
}
static int
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 1514715..df72c5d 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -263,6 +263,8 @@ static void qemuMonitorDispose(void *obj)
virJSONValueFree(mon->options);
VIR_FREE(mon->balloonpath);
VIR_FORCE_CLOSE(mon->logfd);
+ if (mon->lastError.code != VIR_ERR_OK)
+ virResetError(&mon->lastError);
}
--
1.7.3.1.msysgit.0
Best Regards,
-WangYufei
10 years, 11 months
[libvirt] [PATCH python] Skip copying manually written python for C APIs which don't exist
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
If the libvirt-override-virXXXX.py file has methods which call
C APIs that don't exist in the version of libvirt built against
we need to skip copying their code.
eg for 0.9.13 libvirt we should not copy the 'listAllDomains'
method.
The way this works is that it breaks the override file into
individual methods by looking for ' def '. It then collects
the contents until the next method start, whereupon it looks
for a libvirtmod.XXXXXX API call. It checks if the XXXXX part
is present in the XML description we have, and if not, it
discards the entire method.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
generator.py | 42 +++++++++++++++++++++++++++++++++++++++++-
1 file changed, 41 insertions(+), 1 deletion(-)
diff --git a/generator.py b/generator.py
index e8d8ea9..a9f98ab 100755
--- a/generator.py
+++ b/generator.py
@@ -1719,11 +1719,51 @@ def buildWrappers(module):
classes.write("\n")
# Append "<classname>.py" to class def, iff it exists
try:
+ wantfuncs = []
extra = open("libvirt-override-" + classname + ".py", "r")
classes.write (" #\n")
classes.write (" # %s methods from %s.py (hand coded)\n" % (classname,classname))
classes.write (" #\n")
- classes.writelines(extra.readlines())
+ cached = None
+
+
+ # Since we compile with older libvirt, we don't want to pull
+ # in manually written python methods which call C methods
+ # that don't exist. This code attempts to detect which
+ # methods to skip by looking at the libvirtmod.XXXX calls
+
+ def shouldSkip(lines):
+ for line in lines:
+ offset = line.find("libvirtmod.")
+ if offset != -1:
+ func = line[offset + 11:]
+ offset = func.find("(")
+ func = func[0:offset]
+ if func not in functions_skipped:
+ return True
+ return False
+
+ for line in extra.readlines():
+ offset = line.find(" def ")
+ if offset != -1:
+ name = line[offset+5:]
+ offset = name.find("(")
+ name = name[0:offset]
+ if cached is not None:
+ if not shouldSkip(cached):
+ classes.writelines(cached)
+ if name == "__del__":
+ cached = None
+ classes.write(line)
+ else:
+ cached = [line]
+ else:
+ if cached is not None:
+ cached.append(line)
+ else:
+ classes.write(line)
+ if not shouldSkip(cached):
+ classes.writelines(cached)
classes.write("\n")
extra.close()
except:
--
1.8.3.1
10 years, 11 months
Re: [libvirt] [libvirt-users] virsh detach typo
by Eric Blake
On 12/02/2013 02:28 PM, Mauricio Tavares wrote:
> [root@vmhost vms]# virsh detach-disk puppet vdb
> error: No found disk whose source path or target is vdb
>
> [root@vmhost vms]# virsh --version
> 0.10.2
> [root@vmhost vms]#
>
> This probably was solved already but if not, "No found disk" probably
> sounds better if it was "No disk found"
Sure. I'm pushing this under the trivial rule:
From aaa7484097333c8194ee6323f5a479e8121cc18c Mon Sep 17 00:00:00 2001
From: Eric Blake <eblake(a)redhat.com>
Date: Mon, 2 Dec 2013 14:40:15 -0700
Subject: [PATCH] virsh: improve grammar in error message
Based on a suggestion from Mauricio Tavares.
* tools/virsh-domain.c (cmdDetachInterface, vshFindDisk): Improve
wording.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
tools/virsh-domain.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 1fe138c..8b80e1e 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -9802,7 +9802,7 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
obj = xmlXPathEval(BAD_CAST buf, ctxt);
if (obj == NULL || obj->type != XPATH_NODESET ||
obj->nodesetval == NULL || obj->nodesetval->nodeNr == 0) {
- vshError(ctl, _("No found interface whose type is %s"), type);
+ vshError(ctl, _("No interface found whose type is %s"), type);
goto cleanup;
}
@@ -9960,7 +9960,7 @@ vshFindDisk(const char *doc,
}
}
- vshError(NULL, _("No found disk whose source path or target is
%s"), path);
+ vshError(NULL, _("No disk found whose source path or target is
%s"), path);
cleanup:
xmlXPathFreeObject(obj);
--
1.8.3.1
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
10 years, 11 months
[libvirt] [PATCH] qemu: add "-boot strict" to commandline whenever possible
by Laine Stump
This resolves:
https://bugzilla.redhat.com/show_bug.cgi?id=888635
(which was already closed as CANTFIX because the qemu "-boot strict"
commandline option wasn't available at the time).
Problem: you couldn't have a domain that used PXE to boot, but also
had an un-bootable disk device *even if that disk wasn't listed in the
boot order*, because if PXE timed out (e.g. due to the bridge
forwarding delay), the BIOS would move on to the next target, which
would be the unbootable disk device (again - even though it wasn't
given a boot order), and get stuck at a "BOOT DISK FAILURE, PRESS ANY
KEY" message until a user intervened.
The solution available since sometime around QEMU 1.5, is to add
"-boot strict=on" to *every* qemu command. When this is done, if any
devices have a boot order specified, then QEMU will *only* attempt to
boot from those devices that have an explicit boot order, ignoring the
rest.
---
src/qemu/qemu_capabilities.c | 3 +++
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 6 ++++++
tests/qemucapabilitiesdata/caps_1.5.3-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.6.0-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.6.50-1.caps | 1 +
tests/qemuxml2argvtest.c | 4 ++++
7 files changed, 17 insertions(+)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 548b988..a68e555 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -243,6 +243,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
"virtio-mmio",
"ich9-intel-hda",
"kvm-pit-lost-tick-policy",
+
+ "boot-strict", /* 160 */
);
struct _virQEMUCaps {
@@ -2279,6 +2281,7 @@ static struct virQEMUCapsCommandLineProps virQEMUCapsCommandLine[] = {
{ "machine", "mem-merge", QEMU_CAPS_MEM_MERGE },
{ "drive", "discard", QEMU_CAPS_DRIVE_DISCARD },
{ "realtime", "mlock", QEMU_CAPS_MLOCK },
+ { "boot-opts", "strict", QEMU_CAPS_BOOT_STRICT },
};
static int
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 02d47c6..aea64ea 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -198,6 +198,7 @@ enum virQEMUCapsFlags {
QEMU_CAPS_DEVICE_VIRTIO_MMIO = 157, /* -device virtio-mmio */
QEMU_CAPS_DEVICE_ICH9_INTEL_HDA = 158, /* -device ich9-intel-hda */
QEMU_CAPS_KVM_PIT_TICK_POLICY = 159, /* kvm-pit.lost_tick_policy */
+ QEMU_CAPS_BOOT_STRICT = 160, /* -boot strict */
QEMU_CAPS_LAST, /* this must always be the last item */
};
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 763417f..84736d7 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -8204,6 +8204,12 @@ qemuBuildCommandLine(virConnectPtr conn,
def->os.bios.rt_delay);
}
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOT_STRICT)) {
+ if (boot_nparams++)
+ virBufferAddChar(&boot_buf, ',');
+ virBufferAddLit(&boot_buf, "strict=on");
+ }
+
if (boot_nparams > 0) {
virCommandAddArg(cmd, "-boot");
diff --git a/tests/qemucapabilitiesdata/caps_1.5.3-1.caps b/tests/qemucapabilitiesdata/caps_1.5.3-1.caps
index 09cf657..2b00449 100644
--- a/tests/qemucapabilitiesdata/caps_1.5.3-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.5.3-1.caps
@@ -131,4 +131,5 @@
<flag name='usb-storage.removable'/>
<flag name='ich9-intel-hda'/>
<flag name='kvm-pit-lost-tick-policy'/>
+ <flag name='boot-strict'/>
</qemuCaps>
diff --git a/tests/qemucapabilitiesdata/caps_1.6.0-1.caps b/tests/qemucapabilitiesdata/caps_1.6.0-1.caps
index 33ee73b..7bce4aa 100644
--- a/tests/qemucapabilitiesdata/caps_1.6.0-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.6.0-1.caps
@@ -135,4 +135,5 @@
<flag name='virtio-mmio'/>
<flag name='ich9-intel-hda'/>
<flag name='kvm-pit-lost-tick-policy'/>
+ <flag name='boot-strict'/>
</qemuCaps>
diff --git a/tests/qemucapabilitiesdata/caps_1.6.50-1.caps b/tests/qemucapabilitiesdata/caps_1.6.50-1.caps
index a66034a..bfaab9d 100644
--- a/tests/qemucapabilitiesdata/caps_1.6.50-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.6.50-1.caps
@@ -134,4 +134,5 @@
<flag name='virtio-mmio'/>
<flag name='ich9-intel-hda'/>
<flag name='kvm-pit-lost-tick-policy'/>
+ <flag name='boot-strict'/>
</qemuCaps>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index dad5973..631ece7 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -418,6 +418,10 @@ mymain(void)
QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_BOOT,
QEMU_CAPS_BOOTINDEX,
QEMU_CAPS_VIRTIO_BLK_SCSI, QEMU_CAPS_VIRTIO_BLK_SG_IO);
+ DO_TEST("boot-strict",
+ QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_BOOT,
+ QEMU_CAPS_BOOTINDEX, QEMU_CAPS_BOOT_STRICT,
+ QEMU_CAPS_VIRTIO_BLK_SCSI, QEMU_CAPS_VIRTIO_BLK_SG_IO);
DO_TEST("bootloader", QEMU_CAPS_DOMID, QEMU_CAPS_KVM);
DO_TEST("reboot-timeout-disabled", QEMU_CAPS_REBOOT_TIMEOUT);
--
1.8.4.2
10 years, 11 months
[libvirt] [PATCH] Fix VMware support for Fusion 6 / Workstation 10
by Brad Ackerman
This patch gets VMware Fusion 6 working, but the support for ThinPrint needs work—I’m not sure what a good way would be to represent that in libvirt; none of the existing virDomainChrType values seem to be appropriate.
Also, what’s the best way to work this into the test suite?
Responds to BZ 1036248.
—
Brad Ackerman N1MNB PGP: 0x9F49A373
brad(a)facefault.org <*> http://bsa.smugmug.com/
10 years, 11 months