[libvirt] [PATCHv2 0/2] S390: Adding support for SCLP Console
by Viktor Mihajlovski
The S390 architecture comes with a native console type (SCLP
console) which is now also supported by current QEMU.
This series is enabling libvirt to configure S390 domains with SCLP
consoles.
The domain XML has to be extended for the new console target types
'sclp' and 'sclplm' (line mode = dumb).
As usual the QEMU driver must do capability probing in order to find
out whether SCLP is supported and format the QEMU command line
for the new console type.
V2 Changes:
Rebased to current master, resolving conflicts.
J.B. Joret (2):
S390: Add SCLP console front end support
S390: Enable SCLP Console in QEMU driver
docs/formatdomain.html.in | 19 ++++++-
docs/schemas/domaincommon.rng | 2 +
src/conf/domain_conf.c | 4 +-
src/conf/domain_conf.h | 2 +
src/qemu/qemu_capabilities.c | 3 ++
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 59 ++++++++++++++++++++++
.../qemuxml2argv-console-sclp.args | 8 +++
.../qemuxml2argvdata/qemuxml2argv-console-sclp.xml | 24 +++++++++
tests/qemuxml2argvtest.c | 3 ++
10 files changed, 123 insertions(+), 2 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-console-sclp.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-console-sclp.xml
--
1.7.12.4
12 years
[libvirt] [PATCH v4] qemu: Allow the user to specify vendor and product for disk
by Osier Yang
QEMU supports setting vendor and product strings for disk since
1.2.0 (only scsi-disk, scsi-hd, scsi-cd support it), this patch
exposes it with new XML elements <vendor> and <product> of disk
device.
v3 - v4:
* Per Paolo's feedback, allows all printable chars.
---
docs/formatdomain.html.in | 11 +++++
docs/schemas/domaincommon.rng | 14 ++++++
src/conf/domain_conf.c | 44 ++++++++++++++++++++
src/conf/domain_conf.h | 2 +
src/libvirt_private.syms | 1 +
src/qemu/qemu_command.c | 29 +++++++++++++
src/util/util.c | 12 +++++
src/util/util.h | 1 +
...qemuxml2argv-disk-scsi-disk-vpd-build-error.xml | 35 ++++++++++++++++
.../qemuxml2argv-disk-scsi-disk-vpd.args | 13 ++++++
.../qemuxml2argv-disk-scsi-disk-vpd.xml | 38 +++++++++++++++++
tests/qemuxml2argvtest.c | 8 ++++
tests/qemuxml2xmltest.c | 2 +
13 files changed, 210 insertions(+), 0 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-vpd-build-error.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-vpd.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-vpd.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 6a3b976..903c069 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1657,6 +1657,17 @@
of 16 hexadecimal digits.
<span class='since'>Since 0.10.1</span>
</dd>
+ <dt><code>vendor</code></dt>
+ <dd>If present, this element specifies the vendor of a virtual hard
+ disk or CD-ROM device. It must not be longer than 8 printable
+ characters.
+ <span class='since'>Since 1.0.1</span>
+ </dd>
+ <dt><code>product</code></dt>
+ <dd>If present, this element specifies the product of a virtual hard
+ disk or CD-ROM device. It must not be longer than 16 printable
+ <span class='since'>Since 1.0.1</span>
+ </dd>
<dt><code>host</code></dt>
<dd>The <code>host</code> element has two attributes "name" and "port",
which specify the hostname and the port number. The meaning of this
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 02ad477..19bf597 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -905,6 +905,20 @@
<ref name="wwn"/>
</element>
</optional>
+ <optional>
+ <element name="vendor">
+ <data type="string">
+ <param name="pattern">[x20-x7E]{0,8}</param>
+ </data>
+ </element>
+ </optional>
+ <optional>
+ <element name="product">
+ <data type="string">
+ <param name="pattern">[x20-x7E]{0,16}</param>
+ </data>
+ </element>
+ </optional>
</interleave>
</define>
<define name="snapshot">
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 047c4fc..e975f74 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -979,6 +979,8 @@ void virDomainDiskDefFree(virDomainDiskDefPtr def)
VIR_FREE(def->mirror);
VIR_FREE(def->auth.username);
VIR_FREE(def->wwn);
+ VIR_FREE(def->vendor);
+ VIR_FREE(def->product);
if (def->auth.secretType == VIR_DOMAIN_DISK_SECRET_TYPE_USAGE)
VIR_FREE(def->auth.secret.usage);
virStorageEncryptionFree(def->encryption);
@@ -3490,6 +3492,8 @@ cleanup:
goto cleanup;
}
+#define VENDOR_LEN 8
+#define PRODUCT_LEN 16
/* Parse the XML definition for a disk
* @param node XML nodeset to parse for disk definition
@@ -3542,6 +3546,8 @@ virDomainDiskDefParseXML(virCapsPtr caps,
char *logical_block_size = NULL;
char *physical_block_size = NULL;
char *wwn = NULL;
+ char *vendor = NULL;
+ char *product = NULL;
if (VIR_ALLOC(def) < 0) {
virReportOOMError();
@@ -3880,6 +3886,36 @@ virDomainDiskDefParseXML(virCapsPtr caps,
if (!virValidateWWN(wwn))
goto error;
+ } else if (!vendor &&
+ xmlStrEqual(cur->name, BAD_CAST "vendor")) {
+ vendor = (char *)xmlNodeGetContent(cur);
+
+ if (strlen(vendor) > VENDOR_LEN) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("disk vendor is more than 8 characters"));
+ goto error;
+ }
+
+ if (!virStrIsPrint(vendor)) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("disk vendor is not printable string"));
+ goto error;
+ }
+ } else if (!product &&
+ xmlStrEqual(cur->name, BAD_CAST "product")) {
+ product = (char *)xmlNodeGetContent(cur);
+
+ if (strlen(vendor) > PRODUCT_LEN) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("disk product is more than 16 characters"));
+ goto error;
+ }
+
+ if (!virStrIsPrint(product)) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("disk product is not printable string"));
+ goto error;
+ }
} else if (xmlStrEqual(cur->name, BAD_CAST "boot")) {
/* boot is parsed as part of virDomainDeviceInfoParseXML */
}
@@ -4176,6 +4212,10 @@ virDomainDiskDefParseXML(virCapsPtr caps,
serial = NULL;
def->wwn = wwn;
wwn = NULL;
+ def->vendor = vendor;
+ vendor = NULL;
+ def->product = product;
+ product = NULL;
if (driverType) {
def->format = virStorageFileFormatTypeFromString(driverType);
@@ -4249,6 +4289,8 @@ cleanup:
VIR_FREE(logical_block_size);
VIR_FREE(physical_block_size);
VIR_FREE(wwn);
+ VIR_FREE(vendor);
+ VIR_FREE(product);
ctxt->node = save_ctxt;
return def;
@@ -12085,6 +12127,8 @@ virDomainDiskDefFormat(virBufferPtr buf,
virBufferAddLit(buf, " <transient/>\n");
virBufferEscapeString(buf, " <serial>%s</serial>\n", def->serial);
virBufferEscapeString(buf, " <wwn>%s</wwn>\n", def->wwn);
+ virBufferEscapeString(buf, " <vendor>%s</vendor>\n", def->vendor);
+ virBufferEscapeString(buf, " <product>%s</product>\n", def->product);
if (def->encryption) {
virBufferAdjustIndent(buf, 6);
if (virStorageEncryptionFormat(buf, def->encryption) < 0)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index c3e8c16..e3522a5 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -591,6 +591,8 @@ struct _virDomainDiskDef {
char *serial;
char *wwn;
+ char *vendor;
+ char *product;
int cachemode;
int error_policy; /* enum virDomainDiskErrorPolicy */
int rerror_policy; /* enum virDomainDiskErrorPolicy */
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 756d7bd..8a1f9df 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1280,6 +1280,7 @@ virSetUIDGID;
virSkipSpaces;
virSkipSpacesAndBackslash;
virSkipSpacesBackwards;
+virStrIsPrint;
virStrToDouble;
virStrToLong_i;
virStrToLong_l;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 02e105d..2217ccd 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2428,6 +2428,13 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
}
}
+ if ((disk->vendor || disk->product) &&
+ disk->bus != VIR_DOMAIN_DISK_BUS_SCSI) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Only scsi disk supports vendor and product"));
+ goto error;
+ }
+
if (disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) {
/* make sure that both the bus and the qemu binary support
* type='lun' (SG_IO).
@@ -2455,6 +2462,11 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
_("Setting wwn is not supported for lun device"));
goto error;
}
+ if (disk->vendor || disk->product) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Setting vendor or product is not supported for lun device"));
+ goto error;
+ }
}
switch (disk->bus) {
@@ -2504,6 +2516,17 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
goto error;
}
+ /* Properties wwn, vendor and product were introduced in the
+ * same QEMU release (1.2.0).
+ */
+ if ((disk->vendor || disk->product) &&
+ !qemuCapsGet(caps, QEMU_CAPS_SCSI_DISK_WWN)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Setting vendor or product for scsi disk is not "
+ "supported by this QEMU"));
+ goto error;
+ }
+
controllerModel =
virDomainDiskFindControllerModel(def, disk,
VIR_DOMAIN_CONTROLLER_TYPE_SCSI);
@@ -2649,6 +2672,12 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
if (disk->wwn)
virBufferAsprintf(&opt, ",wwn=%s", disk->wwn);
+ if (disk->vendor)
+ virBufferAsprintf(&opt, ",vendor=%s", disk->vendor);
+
+ if (disk->product)
+ virBufferAsprintf(&opt, ",product=%s", disk->product);
+
if (virBufferError(&opt)) {
virReportOOMError();
goto error;
diff --git a/src/util/util.c b/src/util/util.c
index 75b18c1..ea5d12e 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -3114,3 +3114,15 @@ virValidateWWN(const char *wwn) {
return true;
}
+
+bool
+virStrIsPrint(const char *str)
+{
+ int i;
+
+ for (i = 0; str[i]; i++)
+ if (!c_isprint(str[i]))
+ return false;
+
+ return true;
+}
diff --git a/src/util/util.h b/src/util/util.h
index 4316ab1..6d5dd03 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -280,4 +280,5 @@ bool virIsDevMapperDevice(const char *dev_name) ATTRIBUTE_NONNULL(1);
bool virValidateWWN(const char *wwn);
+bool virStrIsPrint(const char *str);
#endif /* __VIR_UTIL_H__ */
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-vpd-build-error.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-vpd-build-error.xml
new file mode 100644
index 0000000..ca68275
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-vpd-build-error.xml
@@ -0,0 +1,35 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>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='cdrom'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='sda' bus='virtio'/>
+ <vendor>SEAGATE</vendor>
+ <product>ST3146707LC</product>
+ </disk>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest2'/>
+ <target dev='sdb' bus='scsi'/>
+ <vendor>SEAGATE</vendor>
+ <product>ST3567807GD</product>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'/>
+ <controller type='scsi' index='0' model='virtio-scsi'/>
+ <controller type='scsi' index='1' model='lsilogic'/>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-vpd.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-vpd.args
new file mode 100644
index 0000000..f5c1999
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-vpd.args
@@ -0,0 +1,13 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test \
+/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults \
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \
+-device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x3 \
+-device lsi,id=scsi1,bus=pci.0,addr=0x4 \
+-usb \
+-drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-scsi0-0-0-0 \
+-device scsi-cd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,\
+id=scsi0-0-0-0,vendor=SEAGATE,product=ST3146707LC \
+-drive file=/dev/HostVG/QEMUGuest2,if=none,id=drive-scsi1-0-0 \
+-device scsi-hd,bus=scsi1.0,scsi-id=0,drive=drive-scsi1-0-0,\
+id=scsi1-0-0,vendor=SEAGATE,product=ST3567807GD \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-vpd.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-vpd.xml
new file mode 100644
index 0000000..96786e3
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-vpd.xml
@@ -0,0 +1,38 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>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='cdrom'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='sda' bus='scsi'/>
+ <readonly/>
+ <vendor>SEAGATE</vendor>
+ <product>ST3146707LC</product>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest2'/>
+ <target dev='sdb' bus='scsi'/>
+ <readonly/>
+ <vendor>SEAGATE</vendor>
+ <product>ST3567807GD</product>
+ <address type='drive' controller='1' bus='0' target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'/>
+ <controller type='scsi' index='0' model='virtio-scsi'/>
+ <controller type='scsi' index='1' model='lsilogic'/>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 4cccbb0..1f69b6c 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -505,6 +505,14 @@ mymain(void)
QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
QEMU_CAPS_SCSI_CD, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI_PCI,
QEMU_CAPS_SCSI_DISK_WWN);
+ DO_TEST("disk-scsi-disk-vpd",
+ QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
+ QEMU_CAPS_SCSI_CD, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI_PCI,
+ QEMU_CAPS_SCSI_DISK_WWN);
+ DO_TEST_FAILURE("disk-scsi-disk-vpd-build-error",
+ QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
+ QEMU_CAPS_SCSI_CD, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI_PCI,
+ QEMU_CAPS_SCSI_DISK_WWN);
DO_TEST("disk-scsi-vscsi",
QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
DO_TEST("disk-scsi-virtio-scsi",
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 1d366f1..88ef050 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -239,6 +239,8 @@ mymain(void)
DO_TEST("seclabel-none");
DO_TEST("numad-static-vcpu-no-numatune");
+ DO_TEST("disk-scsi-disk-vpd");
+
/* These tests generate different XML */
DO_TEST_DIFFERENT("balloon-device-auto");
DO_TEST_DIFFERENT("channel-virtio-auto");
--
1.7.7.6
12 years
[libvirt] [PATCH] lxc: Avoid segfault of libvirt_lxc helper on early cleanup paths
by Peter Krempa
Early jumps to the cleanup label caused a crash of the libvirt_lxc
container helper as the cleanup section called
virLXCControllerDeleteInterfaces(ctrl) without checking the ctrl argument
for NULL. The argument was de-referenced soon after.
$ /usr/libexec/libvirt_lxc
/usr/libexec/libvirt_lxc: missing --name argument for configuration
Segmentation fault
---
src/lxc/lxc_controller.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index a9d2d40..ea5bc58 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -1672,7 +1672,8 @@ int main(int argc, char *argv[])
cleanup:
virPidFileDelete(LXC_STATE_DIR, name);
- virLXCControllerDeleteInterfaces(ctrl);
+ if (ctrl)
+ virLXCControllerDeleteInterfaces(ctrl);
for (i = 0 ; i < nttyFDs ; i++)
VIR_FORCE_CLOSE(ttyFDs[i]);
VIR_FREE(ttyFDs);
--
1.8.0
12 years
[libvirt] [PATCH] lxc: Don't crash if no security driver is specified in libvirt_lxc
by Peter Krempa
When no security driver is specified libvirt_lxc segfaults as a debug
message tries to access security labels for the container that are not
present.
This problem was introduced in commit 6c3cf57d6cb27cf10064baf8cca0f39.
---
src/lxc/lxc_controller.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index ea5bc58..16cda9d 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -1612,11 +1612,15 @@ int main(int argc, char *argv[])
false, false, false)))
goto cleanup;
- VIR_DEBUG("Security model %s type %s label %s imagelabel %s",
- NULLSTR(ctrl->def->seclabels[0]->model),
- virDomainSeclabelTypeToString(ctrl->def->seclabels[0]->type),
- NULLSTR(ctrl->def->seclabels[0]->label),
- NULLSTR(ctrl->def->seclabels[0]->imagelabel));
+ if (ctrl->def->seclabels) {
+ VIR_DEBUG("Security model %s type %s label %s imagelabel %s",
+ NULLSTR(ctrl->def->seclabels[0]->model),
+ virDomainSeclabelTypeToString(ctrl->def->seclabels[0]->type),
+ NULLSTR(ctrl->def->seclabels[0]->label),
+ NULLSTR(ctrl->def->seclabels[0]->imagelabel));
+ } else {
+ VIR_DEBUG("Security model not initialized");
+ }
ctrl->veths = veths;
ctrl->nveths = nveths;
--
1.8.0
12 years
[libvirt] [test-API][PATCH] Add managedsave test cases
by hongming
The managedsave test cases and test suite cover test include
verifying virsh commands managedsave(include all flags and their
combination)/managedsave-remove and managedSaveRemove/ManagedSave/
hasManagedSaveImage python APIs.
The following new files be created.
new file: cases/managedsave.conf
- Test all test cases
new file: repos/managedsave/__init__.py
new file: repos/managedsave/managedsave.py
- Test mangaedsave command/API and all flags
new file: repos/managedsave/managedsave_remove.py
- Test managedsave-remove command/API
new file: repos/managedsave/managedsave_start.py
- Verfiy managedsave'flags and start from managedsave image
---
cases/managedsave.conf | 63 ++++++++++++
repos/managedsave/managedsave.py | 162 +++++++++++++++++++++++++++++++
repos/managedsave/managedsave_remove.py | 61 ++++++++++++
repos/managedsave/managedsave_start.py | 152 +++++++++++++++++++++++++++++
4 files changed, 438 insertions(+), 0 deletions(-)
create mode 100644 cases/managedsave.conf
create mode 100644 repos/managedsave/__init__.py
create mode 100644 repos/managedsave/managedsave.py
create mode 100644 repos/managedsave/managedsave_remove.py
create mode 100644 repos/managedsave/managedsave_start.py
diff --git a/cases/managedsave.conf b/cases/managedsave.conf
new file mode 100644
index 0000000..8dcafe2
--- /dev/null
+++ b/cases/managedsave.conf
@@ -0,0 +1,63 @@
+domain:install_linux_cdrom
+ guestname
+ $defaultname
+ guestos
+ $defaultos
+ guestarch
+ $defaultarch
+ vcpu
+ $defaultvcpu
+ memory
+ $defaultmem
+ hddriver
+ $defaulthd
+ nicdriver
+ $defaultnic
+ imageformat
+ qcow2
+ macaddr
+ 54:52:00:4a:16:30
+
+#VIR_DOMAIN_SAVE_BYPASS_CACHE = 1
+#VIR_DOMAIN_SAVE_RUNNING = 2
+#VIR_DOMAIN_SAVE_PAUSED = 4
+#No_FLAGS = 0
+managedsave:managedsave
+ guestname
+ $defaultname
+ flags
+ 1|2
+
+managedsave:managedsave_start
+ guestname
+ $defaultname
+ flags
+ noping
+
+managedsave:managedsave
+ guestname
+ $defaultname
+ flags
+ 1|4
+
+managedsave:managedsave_start
+ guestname
+ $defaultname
+ flags
+ noping
+
+managedsave:managedsave
+ guestname
+ $defaultname
+ flags
+ 0
+
+managedsave:managedsave_remove
+ guestname
+ $defaultname
+
+managedsave:managedsave_start
+ guestname
+ $defaultname
+ flags
+ noping
diff --git a/repos/managedsave/__init__.py b/repos/managedsave/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/repos/managedsave/managedsave.py b/repos/managedsave/managedsave.py
new file mode 100644
index 0000000..5e7c105
--- /dev/null
+++ b/repos/managedsave/managedsave.py
@@ -0,0 +1,162 @@
+#!/usr/bin/env python
+
+import os
+import math
+
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+from utils import utils
+
+required_params = ('guestname', 'flags',)
+optional_params = {}
+
+def check_guest_status(*args):
+ """Check guest current status"""
+ (domobj, logger) = args
+ state = domobj.info()[0]
+ logger.debug("current guest status: %s" % state)
+
+ if state == libvirt.VIR_DOMAIN_SHUTOFF or \
+ state == libvirt.VIR_DOMAIN_SHUTDOWN or \
+ state == libvirt.VIR_DOMAIN_BLOCKED:
+ return False
+ else:
+ return True
+
+def check_savefile_create(*args):
+ """Check guest's managed save file be created"""
+
+ (guestname) = args
+ cmds = "ls /var/lib/libvirt/qemu/save/%s" % guestname + ".save -lh"
+ logger.info("Execute cmd %s" % cmds)
+ (status, output) = utils.exec_cmd(cmds, shell=True)
+ if status != 0:
+ logger.error("No managed save file")
+ return False
+ else :
+ logger.info("managed save file exists")
+ return True
+
+def compare_cachedfile(cachebefore, cacheafter):
+ """Compare cached value before managed save and its value after
+ managed save """
+
+ diff = cacheafter - cachebefore
+ logger.info("diff is %s " % diff)
+ percent = math.fabs(diff)/cachebefore
+ logger.info("diff percent is %s " % percent)
+ if math.fabs(diff)/cachebefore < 0.05:
+ return True
+ else:
+ return False
+
+def get_cachevalue():
+ """Get the file system cached value """
+
+ cmds = "head -n4 /proc/meminfo|grep Cached|awk '{print $2}'"
+ (status, output) = utils.exec_cmd(cmds, shell=True)
+ if status != 0:
+ logger.error("failed to run cmd line to get cache")
+ return 1
+ else:
+ logger.debug(output[0])
+ cachevalue= int(output[0])
+ return cachevalue
+
+def managedsave(params):
+ """Managed save a running domain"""
+
+ global logger
+ logger = params['logger']
+ guestname = params['guestname']
+ flags = params ['flags']
+ #Save given flags to sharedmod.data
+ sharedmod.data['flagsave'] = flags
+
+ logger.info("The given flags are %s " % flags)
+ if not '|' in flags:
+ flagn = int(flags)
+ else:
+ flagstr = flags.split('|')
+ flagcont = ''.join(flagstr)
+ length = len(flagcont)
+ # bitwise-OR of flags of managedsave
+ flagn = int(flagcont[0])
+ for i in range(0,length-1):
+ flagn = flagn |int(flagcont[i+1])
+
+ conn = sharedmod.libvirtobj['conn']
+ domobj = conn.lookupByName(guestname)
+
+ if not check_guest_status(domobj, logger):
+ logger.error("Error: current guest status is shutoff")
+ return 1
+
+ try:
+
+ logger.info("bitwise OR value of flags is %s" % flagn)
+
+ if flagn == 0:
+ logger.info("managedsave %s domain with no flag" % guestname)
+ elif flagn == 1:
+ logger.info("managedsave %s domain --bypass-cache" % guestname)
+ elif flagn == 2:
+ logger.info("managedsave %s domain --running" % guestname)
+ elif flagn == 3:
+ logger.info("managedsave %s domain --running --bypass-cache"\
+ % guestname)
+ elif flagn == 4:
+ logger.info("managedsave %s domain --paused" % guestname)
+ elif flagn == 5:
+ logger.info("managedsave %s domain --paused --bypass-cache"\
+ % guestname)
+ elif flagn == 6:
+ logger.error("Error:--running and --paused are mutually exclusive")
+ return 1
+ elif flagn == 7:
+ logger.error("Error:--running and --paused are mutually exclusive")
+ return 1
+ else:
+ logger.error("Error:Wrong flags be given and fail to \
+ managedsave domain")
+ return 1
+
+ #If given flags include bypass-cache,check if bypass file system cache
+ if flagn %2 == 1:
+ logger.info("Given flags include --bypass-cache")
+ os.system('echo 3 > /proc/sys/vm/drop_caches')
+ cache_before = get_cachevalue()
+ logger.info("Cached value before managedsave is %s" % cache_before)
+
+ domobj.managedSave(flagn)
+
+ cache_after = get_cachevalue()
+ logger.info("Cached value after managedsave is %s" % cache_after)
+
+ if compare_cachedfile(cache_before, cache_after):
+ logger.info("Bypass file system cache successfully")
+ else:
+ logger.error("Bypass file system cache failed")
+ return 1
+ else:
+ domobj.managedSave(flagn)
+
+ #Check if domain has managedsave image
+ if domobj.hasManagedSaveImage(0) and \
+ domobj.info()[0]==libvirt.VIR_DOMAIN_SHUTOFF and \
+ check_savefile_create(guestname):
+ logger.info("Domain %s managedsave successfully " % guestname)
+ else:
+ logger.error("Error: fail to managedsave domain")
+ return 1
+
+ except libvirtError, e:
+ logger.error("API error message: %s, error code is %s" \
+ % e.message)
+ logger.error("Error: fail to managedsave %s domain" % guestname)
+ return 1
+
+ return 0
+
diff --git a/repos/managedsave/managedsave_remove.py b/repos/managedsave/managedsave_remove.py
new file mode 100644
index 0000000..143312f
--- /dev/null
+++ b/repos/managedsave/managedsave_remove.py
@@ -0,0 +1,61 @@
+#!/usr/bin/env python
+# Save domain as a statefile
+
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+from utils import utils
+
+required_params = ('guestname',)
+optional_params = {}
+
+def check_savefile_remove(*args):
+ """Check if guest's managedsave file be removed """
+
+ (guestname) = args
+ cmds = "ls /var/lib/libvirt/qemu/save/%s" % guestname + ".save -lh"
+ logger.info("Execute cmd %s" % cmds)
+ (status, output) = utils.exec_cmd(cmds, shell=True)
+ if status != 0:
+ logger.info("No managed save file")
+ return True
+ else :
+ logger.error("managed save file exits")
+ return False
+
+
+def managedsave_remove(params):
+ """Remove an existing managed save state file from a domain"""
+
+ global logger
+ logger = params['logger']
+ guestname = params['guestname']
+
+ conn = sharedmod.libvirtobj['conn']
+ domobj = conn.lookupByName(guestname)
+
+ if not domobj.hasManagedSaveImage(0) and check_savefile_remove(guestname):
+ logger.info("Domain %s hasn't managedsave image" % guestname)
+ return 1
+ else:
+ logger.info("Domain %s has managedsave image" % guestname)
+
+ try:
+ domobj.managedSaveRemove(0)
+ #Check if domain has managedsave image
+ if not domobj.hasManagedSaveImage(0) and \
+ check_savefile_remove(guestname):
+ logger.info("Domain %s's managedsave image has been removed"\
+ % guestname)
+ else:
+ logger.error("Error: fail to remove managedsave domain")
+ return 1
+
+ except libvirtError, e:
+ logger.error("API error message: %s, error code is %s" % e.message)
+ logger.error("Error: fail to managedsave %s domain" % guestname)
+ return 1
+
+ return 0
+
diff --git a/repos/managedsave/managedsave_start.py b/repos/managedsave/managedsave_start.py
new file mode 100644
index 0000000..f5da0b3
--- /dev/null
+++ b/repos/managedsave/managedsave_start.py
@@ -0,0 +1,152 @@
+#!/usr/bin/env python
+
+import time
+
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+from utils import utils
+
+required_params = ('guestname',)
+optional_params = {'flags' : ''}
+
+NONE = 0
+START_PAUSED = 1
+START_BYPASS_CACHE = 4
+START_FORCE_BOOT = 8
+
+def check_savefile_remove(*args):
+ """Check guest managed save file"""
+ (guestname) = args
+ cmds = "ls /var/lib/libvirt/qemu/save/%s" % guestname + ".save -lh"
+ logger.info("Execute cmd %s" % cmds)
+ (status, output) = utils.exec_cmd(cmds, shell=True)
+ if status != 0:
+ logger.info("No managed save file")
+ return True
+ else :
+ logger.error("managed save file exists")
+ return False
+
+def managedsave_start(params):
+ """ Start domain with managedsave image and check if its status is rigth
+ according to given flags of running managedsave command.If it is
+ correctly paused , resume it.
+
+ Argument is a dictionary with two keys:
+ {'logger': logger, 'guestname': guestname}
+
+ logger -- an object of utils/log.py
+ mandatory arguments : guestname -- same as the domain name
+ optional arguments : flags -- domain create flags <none|start_paused
+ |noping>.It allows only one flag be given.
+
+ Return 0 on SUCCESS or 1 on FAILURE
+ """
+ domname = params['guestname']
+ global logger
+ logger = params['logger']
+ flags = params.get('flags', '')
+ # Get given flags of managedsave
+ if sharedmod.data.has_key('flagsave'):
+ flagsave = sharedmod.data.get('flagsave')
+ else:
+ logger.error("Failed to get flags from managedsave")
+ # Clean sharedmod.data
+ sharedmod.data = {}
+
+ conn = sharedmod.libvirtobj['conn']
+ domobj = conn.lookupByName(domname)
+
+ timeout = 600
+ logger.info('start domain')
+ # Check if guest has managedsave image before start
+ if domobj.hasManagedSaveImage(0) :
+ logger.info("Domain has managedsave image")
+ else:
+ logger.info("Domain hasn't managedsave image")
+
+ try:
+ if "none" in flags:
+ domobj.createWithFlags(NONE)
+ elif "start_paused" in flags:
+ domobj.createWithFlags(START_PAUSED)
+ else:
+ # this covers flags = None as well as flags = 'noping'
+ domobj.create()
+ except libvirtError, e:
+ logger.error("API error message: %s, error code is %s" \
+ % e.message)
+ logger.error("start failed")
+ return 1
+
+ while timeout:
+ state = domobj.info()[0]
+ expect_states = [libvirt.VIR_DOMAIN_RUNNING,libvirt.VIR_DOMAIN_PAUSED,\
+ libvirt.VIR_DOMAIN_NOSTATE,libvirt.VIR_DOMAIN_BLOCKED]
+
+ if state in expect_states:
+ break
+
+ time.sleep(10)
+ timeout -= 10
+ logger.info(str(timeout) + "s left")
+
+ if timeout <= 0:
+ logger.error('The domain state is not as expected, state: ' + state)
+ return 1
+
+ logger.info("Guest started")
+
+ """If domain's current state is paused. Check if start command has
+ --paused flag or managedsave has --paused flag (given flags in managedsave
+ include '4'). If yes, it means domain successfully paused , then resume it.
+ If not, throw error -guest state error."""
+
+ if state == libvirt.VIR_DOMAIN_PAUSED:
+ if "start_paused" in flags or "4" in flagsave:
+ logger.info("Guest paused successfully ")
+
+ try:
+ domobj.resume()
+
+ except libvirtError, e:
+ logger.error("API error message: %s, error code is %s" \
+ % e.message)
+ logger.error("resume failed")
+ return 1
+ stateresume = domobj.info()[0]
+ expect_states = [libvirt.VIR_DOMAIN_RUNNING, \
+ libvirt.VIR_DOMAIN_NOSTATE, \
+ libvirt.VIR_DOMAIN_BLOCKED]
+ if stateresume not in expect_states:
+ logger.error('The domain state is not equal to "paused"')
+ return 1
+ else:
+ logger.info('Domain resume successfully')
+ return 0
+ else:
+ logger.error("guest state error")
+ return 1
+
+ # Get domain ip and ping ip to check domain's status
+ if not "noping" in flags:
+ mac = utils.get_dom_mac_addr(domname)
+ logger.info("get ip by mac address")
+ ip = utils.mac_to_ip(mac, 180)
+
+ logger.info('ping guest')
+ if not utils.do_ping(ip, 300):
+ logger.error('Failed on ping guest, IP: ' + str(ip))
+ return 1
+
+ # Check if domain' managedsave image exists,if not, return 0.
+ if not domobj.hasManagedSaveImage(0) and check_savefile_remove(domname):
+ logger.info("Domain %s with managedsave image successfully start" \
+ % domname)
+ return 0
+ else:
+ logger.info("Failed to start domain s% with managedsave image" \
+ % domname)
+ return 1
--
1.7.7.6
12 years
[libvirt] [PATCH] cpu: Add Intel Haswell cpu model
by Peter Krempa
The new model supports following features in addition to those supported
by SandyBridge:
fma, movbe, fsgsbase, bmi1, hle, avx2, smep, bmi2, erms, invpcid, rtm
---
Based on: https://lists.gnu.org/archive/html/qemu-devel/2012-11/msg01328.html
---
src/cpu/cpu_map.xml | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml
index 7ff91be..eb69a34 100644
--- a/src/cpu/cpu_map.xml
+++ b/src/cpu/cpu_map.xml
@@ -495,6 +495,22 @@
<feature name='rdtscp'/>
</model>
+ <model name='Haswell'>
+ <model name='SandyBridge'/>
+ <feature name='fma'/>
+ <feature name='pcid'/>
+ <feature name='movbe'/>
+ <feature name='fsgsbase'/>
+ <feature name='bmi1'/>
+ <feature name='hle'/>
+ <feature name='avx2'/>
+ <feature name='smep'/>
+ <feature name='bmi2'/>
+ <feature name='erms'/>
+ <feature name='invpcid'/>
+ <feature name='rtm'/>
+ </model>
+
<!-- AMD CPUs -->
<model name='athlon'>
<model name='pentiumpro'/>
--
1.8.0
12 years
[libvirt] [PATCH] storage: fix logical volume cloning
by Ján Tomko
Commit 258e06c removed setting of the volume type to
VIR_STORAGE_VOL_BLOCK, which leads to failures in
storageVolumeCreateXMLFrom.
The type (and target.format) of the volume was set to zero. In
virStorageBackendGetBuildVolFromFunction, this gets interpreted as
VIR_STORAGE_FILE_NONE and the qemu-img tool is called with unknown
"none" format.
Bug: https://bugzilla.redhat.com/show_bug.cgi?id=879780
---
src/storage/storage_backend_logical.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c
index de43c3a..fd5cbd1 100644
--- a/src/storage/storage_backend_logical.c
+++ b/src/storage/storage_backend_logical.c
@@ -708,6 +708,8 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn,
return -1;
}
+ vol->type = VIR_STORAGE_VOL_BLOCK;
+
if (vol->target.path != NULL) {
/* A target path passed to CreateVol has no meaning */
VIR_FREE(vol->target.path);
--
1.7.8.6
12 years
[libvirt] [PATCH] build: fix build --without-network
by Ján Tomko
bridge_driver.h: silence gcc warnings:
statement with no effect [-Wunused-value]
unused variable 'net' [-Wunused-variable]
virdrivermoduletest.c: don't require network driver module
if it hasn't been built.
---
src/network/bridge_driver.h | 4 ++--
tests/virdrivermoduletest.c | 8 ++++++++
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/network/bridge_driver.h b/src/network/bridge_driver.h
index 0fae275..1c42d81 100644
--- a/src/network/bridge_driver.h
+++ b/src/network/bridge_driver.h
@@ -53,8 +53,8 @@ int networkBuildDhcpDaemonCommandLine(virNetworkObjPtr network,
# else
/* Define no-op replacements that don't drag in any link dependencies. */
# define networkAllocateActualDevice(iface) 0
-# define networkNotifyActualDevice(iface) 0
-# define networkReleaseActualDevice(iface) 0
+# define networkNotifyActualDevice(iface) (iface=iface,0)
+# define networkReleaseActualDevice(iface) (iface=iface,0)
# define networkGetNetworkAddress(netname, netaddr) (-2)
# define networkBuildDhcpDaemonCommandLine(network, cmdout, pidfile, dctx) 0
# endif
diff --git a/tests/virdrivermoduletest.c b/tests/virdrivermoduletest.c
index 9c14e79..0123c36 100644
--- a/tests/virdrivermoduletest.c
+++ b/tests/virdrivermoduletest.c
@@ -83,10 +83,18 @@ mymain(void)
TEST("interface", NULL);
#endif
#ifdef WITH_QEMU
+# ifdef WITH_NETWORK
TEST("qemu", "network");
+# else
+ TEST("qemu", NULL);
+# endif
#endif
#ifdef WITH_LXC
+# ifdef WITH_NETWORK
TEST("lxc", "network");
+# else
+ TEST("lxc", NULL);
+# endif
#endif
#ifdef WITH_UML
TEST("uml", NULL);
--
1.7.8.6
12 years
[libvirt] libvirt [PATCHv2 0/2] Refactor ESX storage driver and append support for iSCSI devices.
by Ata E Husain Bohra
Major changes:
Split changes to two parts:
a. Refactor ESX storage driver to implement facade design.
b. Add backend driver to support iSCSI devices.
Ata E Husain Bohra (2):
Refactor ESX storage driver to implement facade pattern
Add iSCSI backend storage driver for ESX.
daemon/remote.c | 6 +-
src/Makefile.am | 2 +
src/conf/storage_conf.c | 3 +-
src/datatypes.c | 25 +-
src/datatypes.h | 24 +-
src/esx/esx_driver.c | 6 +-
src/esx/esx_storage_backend_iscsi.c | 807 +++++++++++++++++++
src/esx/esx_storage_backend_iscsi.h | 29 +
src/esx/esx_storage_backend_vmfs.c | 1491 +++++++++++++++++++++++++++++++++++
src/esx/esx_storage_backend_vmfs.h | 30 +
src/esx/esx_storage_driver.c | 1325 +++++--------------------------
src/esx/esx_vi.c | 337 +++++++-
src/esx/esx_vi.h | 21 +-
src/esx/esx_vi_generator.input | 302 +++++++
src/esx/esx_vi_generator.py | 19 +
src/parallels/parallels_storage.c | 24 +-
src/remote/remote_driver.c | 6 +-
src/storage/storage_driver.c | 28 +-
src/test/test_driver.c | 30 +-
src/vbox/vbox_tmpl.c | 14 +-
20 files changed, 3357 insertions(+), 1172 deletions(-)
create mode 100644 src/esx/esx_storage_backend_iscsi.c
create mode 100644 src/esx/esx_storage_backend_iscsi.h
create mode 100644 src/esx/esx_storage_backend_vmfs.c
create mode 100644 src/esx/esx_storage_backend_vmfs.h
--
1.7.9.5
12 years
[libvirt] [PATCH 0/6 v2] Unprivileged SG_IO support
by Osier Yang
Hi,
As a result of RFC [1], this implements the unprivleged SG_IO
support. Though it is a bit rushed, and I still have no chance
to test it yet, but I'd like see an earlier reviewing.
@Paolo, please let me known once you have a kernel build with
the new sysfs knob supported. Thanks!
Osier Yang (6):
unpriv_sgio: Add docs and rng schema for new XML unpriv_sgio
unpriv_sgio: Parse and format the new XML
unpriv_sgio: Prepare helpers for unpriv_sgio setting
unpriv_sgio: Manage unpriv_sgio in domain's lifecyle
unpriv_sgio: Do not restore unpriv_sgio if the disk is being used
unpriv_sgio: Error out if the unpriv_sgio setting conflicts with others
docs/formatdomain.html.in | 10 +-
docs/schemas/domaincommon.rng | 52 ++++--
src/conf/domain_conf.c | 168 ++++++++++++++++++--
src/conf/domain_conf.h | 18 ++
src/libvirt_private.syms | 6 +
src/qemu/qemu_process.c | 54 +++++++
src/util/util.c | 154 ++++++++++++++++++
src/util/util.h | 7 +
...l2argv-disk-scsi-lun-passthrough-upriv-sgio.xml | 32 ++++
tests/qemuxml2xmltest.c | 1 +
10 files changed, 472 insertions(+), 30 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-lun-passthrough-upriv-sgio.xml
[1] https://www.redhat.com/archives/libvir-list/2012-November/msg00988.html
Regards,
Osier
12 years