[libvirt] [PATCH v2 1/1] Set legacy USB option with default for ppc64.
by Li Zhang
From: Li Zhang <zhlcindy(a)linux.vnet.ibm.com>
Currently, -device xxx still can't work well for ppc64 platform.
It's better use legacy USB option with default for ppc64.
This patch is to legacy USB option with default for ppc64.
Signed-off-by: Li Zhang <zhlcindy(a)linux.vnet.ibm.com>
---
v2 -> v1:
* Add test cases for USB controller configuration on PPC64.
src/qemu/qemu_command.c | 3 ++-
.../qemuxml2argv-pseries-usb-default.args | 1 +
.../qemuxml2argv-pseries-usb-default.xml | 17 +++++++++++++++++
.../qemuxml2argv-pseries-usb-multi.args | 1 +
.../qemuxml2argv-pseries-usb-multi.xml | 19 +++++++++++++++++++
tests/qemuxml2argvtest.c | 8 ++++++++
6 files changed, 48 insertions(+), 1 deletion(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-default.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-default.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-multi.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-multi.xml
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 63b9350..a48eada 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6467,7 +6467,8 @@ qemuBuildCommandLine(virConnectPtr conn,
}
} else if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_USB &&
cont->model == -1 &&
- !virQEMUCapsGet(qemuCaps, QEMU_CAPS_PIIX3_USB_UHCI)) {
+ (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_PIIX3_USB_UHCI) ||
+ def->os.arch == VIR_ARCH_PPC64)) {
if (usblegacy) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Multiple legacy USB controllers are "
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-default.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-default.args
new file mode 100644
index 0000000..745910b
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-default.args
@@ -0,0 +1 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu-system-ppc64 -S -M pseries -m 512 -smp 1 -nographic -nodefconfig -nodefaults -chardev socket,id=charmonitor,path=/tmp/test-monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=readline -no-acpi -boot c -usb -chardev pty,id=charserial0 -device spapr-vty,chardev=charserial0,reg=0x30000000
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-default.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-default.xml
new file mode 100644
index 0000000..e62a78c
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-default.xml
@@ -0,0 +1,17 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
+ <memory unit='KiB'>524288</memory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='ppc64' machine='pseries'>hvm</type>
+ </os>
+ <clock offset='utc'/>
+ <devices>
+ <emulator>/usr/bin/qemu-system-ppc64</emulator>
+ <console type='pty'>
+ <address type="spapr-vio"/>
+ </console>
+ <memballoon model="none"/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-multi.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-multi.args
new file mode 100644
index 0000000..ac17b8c
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-multi.args
@@ -0,0 +1 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu-system-ppc64 -S -M pseries -m 512 -smp 1 -nographic -nodefconfig -nodefaults -chardev socket,id=charmonitor,path=/tmp/test-monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=readline -no-acpi -boot c -device piix3-usb-uhci,id=usb,bus=pci,addr=0x1.0x2 -device pci-ohci,id=usb1,bus=pci,addr=0x3 -chardev pty,id=charserial0 -device spapr-vty,chardev=charserial0,reg=0x30000000
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-multi.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-multi.xml
new file mode 100644
index 0000000..f45d9d1
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-multi.xml
@@ -0,0 +1,19 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
+ <memory unit='KiB'>524288</memory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='ppc64' machine='pseries'>hvm</type>
+ </os>
+ <clock offset='utc'/>
+ <devices>
+ <emulator>/usr/bin/qemu-system-ppc64</emulator>
+ <console type='pty'>
+ <address type="spapr-vio"/>
+ </console>
+ <controller type='usb' index='0' model='piix3-uhci'/>
+ <controller type='usb' index='1' model='pci-ohci'/>
+ <memballoon model="none"/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index be6c759..3bbe395 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -902,6 +902,14 @@ mymain(void)
QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
DO_TEST("pseries-vio", QEMU_CAPS_DRIVE,
QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
+ DO_TEST("pseries-usb-default", QEMU_CAPS_DRIVE,
+ QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE,
+ QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_PIIX3_USB_UHCI,
+ QEMU_CAPS_PCI_OHCI, QEMU_CAPS_PCI_MULTIFUNCTION);
+ DO_TEST("pseries-usb-multi", QEMU_CAPS_DRIVE,
+ QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE,
+ QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_PIIX3_USB_UHCI,
+ QEMU_CAPS_PCI_OHCI, QEMU_CAPS_PCI_MULTIFUNCTION);
DO_TEST("pseries-vio-user-assigned", QEMU_CAPS_DRIVE,
QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
DO_TEST_ERROR("pseries-vio-address-clash", QEMU_CAPS_DRIVE,
--
1.8.1.4
12 years
[libvirt] [PATCH designer] Adapt saner libtool versioning scheme from libvirt
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
The current way libtool versioning is calculated has a timebomb
when the package version number changes to 1.0.0, which will
cause the library soname to change. Adapt to the latest libvirt
macros for libtool versioning, which use an explicit variable
LIBVIRT_DESIGNER_SONUM setting for changing soname.
---
configure.ac | 40 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 39 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index c999826..2a55f75 100644
--- a/configure.ac
+++ b/configure.ac
@@ -19,9 +19,47 @@ LIBVIRT_DESIGNER_MAJOR_VERSION=`echo $VERSION | awk -F. '{print $1}'`
LIBVIRT_DESIGNER_MINOR_VERSION=`echo $VERSION | awk -F. '{print $2}'`
LIBVIRT_DESIGNER_MICRO_VERSION=`echo $VERSION | awk -F. '{print $3}'`
LIBVIRT_DESIGNER_VERSION=$LIBVIRT_DESIGNER_MAJOR_VERSION.$LIBVIRT_DESIGNER_MINOR_VERSION.$LIBVIRT_DESIGNER_MICRO_VERSION$LIBVIRT_DESIGNER_MICRO_VERSION_SUFFIX
-LIBVIRT_DESIGNER_VERSION_INFO=`expr $LIBVIRT_DESIGNER_MAJOR_VERSION + $LIBVIRT_DESIGNER_MINOR_VERSION`:$LIBVIRT_DESIGNER_MICRO_VERSION:$LIBVIRT_DESIGNER_MINOR_VERSION
LIBVIRT_DESIGNER_VERSION_NUMBER=`expr $LIBVIRT_DESIGNER_MAJOR_VERSION \* 1000000 + $LIBVIRT_DESIGNER_MINOR_VERSION \* 1000 + $LIBVIRT_DESIGNER_MICRO_VERSION`
+# In libtool terminology we need to figure out:
+#
+# CURRENT
+# The most recent interface number that this library implements.
+#
+# REVISION
+# The implementation number of the CURRENT interface.
+#
+# AGE
+# The difference between the newest and oldest interfaces that this
+# library implements.
+#
+# In other words, the library implements all the interface numbers
+# in the range from number `CURRENT - AGE' to `CURRENT'.
+#
+# Libtool assigns the soname version from `CURRENT - AGE', and we
+# don't want that to ever change in libvirt. ie it must always be
+# zero, to produce libvirt.so.0.
+#
+# We would, however, like the libvirt-designer version number reflected
+# in the so version'd symlinks, and this is based on AGE.REVISION
+# eg libvirt-designer.so.0.AGE.REVISION
+#
+# Assuming we do ever want to break soname version, this can
+# toggled. But seriously, don't touch this, unless we explicitly
+# agree to break ABI on the mailing list.
+LIBVIRT_DESIGNER_SONUM=0
+
+# The following examples show what libtool will do
+#
+# Input: 0.9.14 -> libvirt-designer.so.0.9.14
+# Input: 1.0.0 -> libvirt-designer.so.0.1000.0
+# Input: 2.5.8 -> libvirt-designer.so.0.2005.8
+#
+AGE=`expr $LIBVIRT_DESIGNER_MAJOR_VERSION '*' 1000 + $LIBVIRT_DESIGNER_MINOR_VERSION`
+REVISION=$LIBVIRT_DESIGNER_MICRO_VERSION
+CURRENT=`expr $LIBVIRT_DESIGNER_SONUM + $AGE`
+LIBVIRT_DESIGNER_VERSION_INFO=$CURRENT:$REVISION:$AGE
+
AC_SUBST([LIBVIRT_DESIGNER_MAJOR_VERSION])
AC_SUBST([LIBVIRT_DESIGNER_MINOR_VERSION])
AC_SUBST([LIBVIRT_DESIGNER_MICRO_VERSION])
--
1.8.1.4
12 years
[libvirt] Reworked patch set to add UID/GID support for containers
by dwalsh@redhat.com
Combined all UID/GID patches, taken into account Dan Berrange feedback.
Now UID will be based off the current UID.
Sandbox Shell is no longer used when using LXC containers. Connect will
now just execute a shell within the container.
[sandbox PATCH 1/6] Add UID/GID support for use with interactive
[sandbox PATCH 2/6] We should not turn on the sanbox shell by
[sandbox PATCH 3/6] Only create the destination directory if it does
12 years
[libvirt] [libvirt-designer][PATCH] test: Add new SimpleDisk test
by Michal Privoznik
This test is meant for adding CDROM, floppy and disk to a domain.
For now, each method has _file and _device variant, which are
tested for now.
---
libvirt-designer/test-designer-domain.c | 101 ++++++++++++++++++++++++++++++++
1 file changed, 101 insertions(+)
diff --git a/libvirt-designer/test-designer-domain.c b/libvirt-designer/test-designer-domain.c
index bbd5a28..90f7e68 100644
--- a/libvirt-designer/test-designer-domain.c
+++ b/libvirt-designer/test-designer-domain.c
@@ -125,6 +125,41 @@ static const gchar *capslxcxml =
" </guest>"
"</capabilities>";
+static const gchar *domain_machine_simple_iso_result =
+ "<domain>\n"
+ " <devices>\n"
+ " <disk type=\"file\">\n"
+ " <source file=\"/foo/bar1\"/>\n"
+ " <driver name=\"qemu\" type=\"raw\"/>\n"
+ " <target bus=\"ide\" dev=\"hda\"/>\n"
+ " </disk>\n"
+ " <disk type=\"block\">\n"
+ " <source dev=\"/foo/bar2\"/>\n"
+ " <driver name=\"qemu\" type=\"raw\"/>\n"
+ " <target bus=\"ide\" dev=\"hdb\"/>\n"
+ " </disk>\n"
+ " <disk type=\"file\">\n"
+ " <source file=\"/foo/bar3\"/>\n"
+ " <driver name=\"qemu\" type=\"qcow2\"/>\n"
+ " <target bus=\"ide\" dev=\"hdc\"/>\n"
+ " </disk>\n"
+ " <disk type=\"block\">\n"
+ " <source dev=\"/foo/bar4\"/>\n"
+ " <driver name=\"qemu\" type=\"raw\"/>\n"
+ " <target bus=\"ide\" dev=\"hdd\"/>\n"
+ " </disk>\n"
+ " <disk type=\"file\">\n"
+ " <source file=\"/foo/bar5\"/>\n"
+ " <driver name=\"qemu\" type=\"bochs\"/>\n"
+ " <target bus=\"ide\" dev=\"hde\"/>\n"
+ " </disk>\n"
+ " <disk type=\"block\">\n"
+ " <source dev=\"/foo/bar6\"/>\n"
+ " <driver name=\"qemu\" type=\"raw\"/>\n"
+ " <target bus=\"ide\" dev=\"hdf\"/>\n"
+ " </disk>\n"
+ " </devices>\n"
+ "</domain>";
static void test_domain_machine_setup(GVirDesignerDomain **design, gconstpointer opaque)
{
@@ -142,6 +177,49 @@ static void test_domain_machine_setup(GVirDesignerDomain **design, gconstpointer
}
+static void test_domain_machine_simple_disk_setup(GVirDesignerDomain **design, gconstpointer opaque)
+{
+ GError *error = NULL;
+ GVirConfigDomainDisk *disk;
+ OsinfoOs *os = osinfo_os_new("http://myoperatingsystem/amazing/4.2");
+ OsinfoDb *db = osinfo_db_new();
+ OsinfoPlatform *platform = osinfo_platform_new("http://myhypervisor.org/awesome/6.6.6");
+ GVirConfigCapabilities *caps = gvir_config_capabilities_new_from_xml(capsqemuxml, NULL);
+
+ *design = gvir_designer_domain_new(db, os, platform, caps);
+ g_assert(*design);
+
+ disk = gvir_designer_domain_add_cdrom_file(*design, "/foo/bar1", "raw", &error);
+ g_assert(disk);
+ g_object_unref(disk);
+
+ disk = gvir_designer_domain_add_cdrom_device(*design, "/foo/bar2", &error);
+ g_assert(disk);
+ g_object_unref(disk);
+
+ disk = gvir_designer_domain_add_disk_file(*design, "/foo/bar3", "qcow2", &error);
+ g_assert(disk);
+ g_object_unref(disk);
+
+ disk = gvir_designer_domain_add_disk_device(*design, "/foo/bar4", &error);
+ g_assert(disk);
+ g_object_unref(disk);
+
+ disk = gvir_designer_domain_add_floppy_file(*design, "/foo/bar5", "bochs", &error);
+ g_assert(disk);
+ g_object_unref(disk);
+
+ disk = gvir_designer_domain_add_disk_device(*design, "/foo/bar6", &error);
+ g_assert(disk);
+ g_object_unref(disk);
+
+ g_object_unref(os);
+ g_object_unref(db);
+ g_object_unref(platform);
+ g_object_unref(caps);
+}
+
+
static void test_domain_container_setup(GVirDesignerDomain **design, gconstpointer opaque)
{
OsinfoOs *os = osinfo_os_new("http://myoperatingsystem/amazing/4.2");
@@ -243,6 +321,22 @@ static void test_domain_machine_alt_arch_run(GVirDesignerDomain **design, gconst
g_object_unref(osconfig);
}
+static void test_domain_machine_simple_disk_run(GVirDesignerDomain **design, gconstpointer opaque)
+{
+ GError *error = NULL;
+ gboolean ret;
+ GVirConfigDomain *config;
+ gchar *xml;
+
+ config = gvir_designer_domain_get_config(*design);
+ xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(config));
+ g_test_message("XML %s", xml);
+ g_assert_cmpstr(xml,
+ ==,
+ domain_machine_simple_iso_result);
+ g_free(xml);
+}
+
static void test_domain_container_host_arch_run(GVirDesignerDomain **design, gconstpointer opaque)
{
GError *error = NULL;
@@ -362,5 +456,12 @@ int main(int argc, char **argv)
test_domain_container_setup,
test_domain_container_alt_arch_run,
test_domain_teardown);
+ g_test_add("/TestDesignerDomain/SimpleDisk",
+ GVirDesignerDomain *,
+ &domain,
+ test_domain_machine_simple_disk_setup,
+ test_domain_machine_simple_disk_run,
+ test_domain_teardown);
+
return g_test_run();
}
--
1.8.1.5
12 years
[libvirt] [PATCH glib] Adopt saner libtool versioning scheme from libvirt
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
The current way libtool versioning is calculated has a timebomb
when the package version number changes to 1.0.0, which will
cause the library soname to change. Adapt to the latest libvirt
macros for libtool versioning, which use an explicit variable
LIBVIRT_GLIB_SONUM setting for changing soname.
---
configure.ac | 39 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index cef5025..360c13f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,9 +21,46 @@ LIBVIRT_GLIB_MAJOR_VERSION=`echo $VERSION | awk -F. '{print $1}'`
LIBVIRT_GLIB_MINOR_VERSION=`echo $VERSION | awk -F. '{print $2}'`
LIBVIRT_GLIB_MICRO_VERSION=`echo $VERSION | awk -F. '{print $3}'`
LIBVIRT_GLIB_VERSION=$LIBVIRT_GLIB_MAJOR_VERSION.$LIBVIRT_GLIB_MINOR_VERSION.$LIBVIRT_GLIB_MICRO_VERSION$LIBVIRT_GLIB_MICRO_VERSION_SUFFIX
-LIBVIRT_GLIB_VERSION_INFO=`expr $LIBVIRT_GLIB_MAJOR_VERSION + $LIBVIRT_GLIB_MINOR_VERSION`:$LIBVIRT_GLIB_MICRO_VERSION:$LIBVIRT_GLIB_MINOR_VERSION
LIBVIRT_GLIB_VERSION_NUMBER=`expr $LIBVIRT_GLIB_MAJOR_VERSION \* 1000000 + $LIBVIRT_GLIB_MINOR_VERSION \* 1000 + $LIBVIRT_GLIB_MICRO_VERSION`
+# In libtool terminology we need to figure out:
+#
+# CURRENT
+# The most recent interface number that this library implements.
+#
+# REVISION
+# The implementation number of the CURRENT interface.
+#
+# AGE
+# The difference between the newest and oldest interfaces that this
+# library implements.
+#
+# In other words, the library implements all the interface numbers
+# in the range from number `CURRENT - AGE' to `CURRENT'.
+#
+# Libtool assigns the soname version from `CURRENT - AGE', and we
+# don't want that to ever change in libvirt. ie it must always be
+# zero, to produce libvirt.so.0.
+#
+# We would, however, like the libvirt-glib version number reflected
+# in the so version'd symlinks, and this is based on AGE.REVISION
+# eg libvirt-glib.so.0.AGE.REVISION
+#
+# Assuming we do ever want to break soname version, this can
+# toggled. But seriously, don't ever touch this.
+LIBVIRT_GLIB_SONUM=0
+
+# The following examples show what libtool will do
+#
+# Input: 0.9.14 -> libvirt-glib.so.0.9.14
+# Input: 1.0.0 -> libvirt-glib.so.0.1000.0
+# Input: 2.5.8 -> libvirt-glib.so.0.2005.8
+#
+AGE=`expr $LIBVIRT_GLIB_MAJOR_VERSION '*' 1000 + $LIBVIRT_GLIB_MINOR_VERSION`
+REVISION=$LIBVIRT_GLIB_MICRO_VERSION
+CURRENT=`expr $LIBVIRT_GLIB_SONUM + $AGE`
+LIBVIRT_GLIB_VERSION_INFO=$CURRENT:$REVISION:$AGE
+
AC_SUBST([LIBVIRT_GLIB_MAJOR_VERSION])
AC_SUBST([LIBVIRT_GLIB_MINOR_VERSION])
AC_SUBST([LIBVIRT_GLIB_MICRO_VERSION])
--
1.8.1.4
12 years
[libvirt] [PATCH designer] Increment soname + symbol versions
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
The ABI of some methods was explicitly broken, so the soname
and symbol versions must all be incremented to reflect the
ABI incompatibility
---
configure.ac | 2 +-
libvirt-designer/libvirt-designer.sym | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index 2a55f75..e70b2e2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -47,7 +47,7 @@ LIBVIRT_DESIGNER_VERSION_NUMBER=`expr $LIBVIRT_DESIGNER_MAJOR_VERSION \* 1000000
# Assuming we do ever want to break soname version, this can
# toggled. But seriously, don't touch this, unless we explicitly
# agree to break ABI on the mailing list.
-LIBVIRT_DESIGNER_SONUM=0
+LIBVIRT_DESIGNER_SONUM=1
# The following examples show what libtool will do
#
diff --git a/libvirt-designer/libvirt-designer.sym b/libvirt-designer/libvirt-designer.sym
index 7a24f2c..6e2e231 100644
--- a/libvirt-designer/libvirt-designer.sym
+++ b/libvirt-designer/libvirt-designer.sym
@@ -1,4 +1,4 @@
-LIBVIRT_DESIGNER_0.0.1 {
+LIBVIRT_DESIGNER_0.0.2 {
global:
gvir_designer_init;
gvir_designer_init_check;
--
1.8.1.4
12 years
[libvirt] [libvirt-designer][PATCH 1/2] cfg.mk: Update list of syntax-check exceptions
by Michal Privoznik
The bindtextdomain syntax-check macro is doing some dumb
checking: each file containing '\<main *(' must call
bindtextdomain. Even if it's mentioned inside a comment block,
which we do as of e71ad8e13e7.
---
Or shall we drop bindtextdomain rule instead?
cfg.mk | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index 54f62d4..1e4b31d 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -104,8 +104,8 @@ sc_copyright_format:
prev_version_file = /dev/null
-exclude_file_name_regexp--sc_bindtextdomain = ^(libvirt-designer/test)|(libvirt-designer/libvirt-designer-init-*)|(examples/virtxml.c)
+exclude_file_name_regexp--sc_bindtextdomain = ^libvirt-designer/(test|libvirt-designer-main\.c)|^examples/virtxml\.c$$
-exclude_file_name_regexp--sc_preprocessor_indentation = ^*/*.[ch]
+exclude_file_name_regexp--sc_preprocessor_indentation = ^*/*.[ch]$$
-exclude_file_name_regexp--sc_prohibit_strcmp = ^libvirt-designer/libvirt-designer-init-qemu.c
+exclude_file_name_regexp--sc_prohibit_strcmp = ^libvirt-designer/libvirt-designer-init-qemu.c$$
--
1.8.1.5
12 years
[libvirt] [PATCH] Virsh command vol-rename
by harryxiyou@gmail.com
From: Harry Wei <harryxiyou(a)gmail.com>
Vol-rename is a convenience function, requiring when
one wanna rename a volume name.
Signed-off-by: Harry Wei <harryxiyou(a)gmail.com>
---
tools/virsh-volume.c | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 103 insertions(+)
diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c
index 0ca295f..8757d54 100644
--- a/tools/virsh-volume.c
+++ b/tools/virsh-volume.c
@@ -490,6 +490,103 @@ cleanup:
}
/*
+ * "vol-rename" command
+ */
+static const vshCmdInfo info_vol_rename[] = {
+ {.name = "help",
+ .data = N_("rename a volume.")
+ },
+ {.name = "desc",
+ .data = N_("Rename an existing volume.")
+ },
+ {.name = NULL}
+};
+
+static const vshCmdOptDef opts_vol_rename[] = {
+ {.name = "vol",
+ .type = VSH_OT_DATA,
+ .flags = VSH_OFLAG_REQ,
+ .help = N_("orig vol name or key")
+ },
+ {.name = "newname",
+ .type = VSH_OT_DATA,
+ .flags = VSH_OFLAG_REQ,
+ .help = N_("new name")
+ },
+ {.name = "pool",
+ .type = VSH_OT_STRING,
+ .help = N_("pool name or uuid")
+ },
+ {.name = NULL}
+};
+
+static bool
+cmdVolRename(vshControl *ctl, const vshCmd *cmd)
+{
+ virStoragePoolPtr origpool = NULL;
+ virStorageVolPtr origvol = NULL, newvol = NULL;
+ const char *origname = NULL;
+ const char *name = NULL;
+ char *origxml = NULL;
+ xmlChar *newxml = NULL;
+ bool ret = false;
+ unsigned int flags = 0;
+
+ if (!(origvol = vshCommandOptVol(ctl, cmd, "vol", "pool", &origname)))
+ goto cleanup;
+
+ origpool = virStoragePoolLookupByVolume(origvol);
+ if (!origpool) {
+ vshError(ctl, "%s", _("failed to get parent pool"));
+ goto cleanup;
+ }
+
+ if (vshCommandOptStringReq(ctl, cmd, "newname", &name) < 0)
+ goto cleanup;
+
+ origxml = virStorageVolGetXMLDesc(origvol, 0);
+ if (!origxml)
+ goto cleanup;
+
+ newxml = vshMakeCloneXML(origxml, name);
+ if (!newxml) {
+ vshPrint(ctl, "%s", _("Failed to allocate XML buffer"));
+ goto cleanup;
+ }
+
+ newvol = virStorageVolCreateXMLFrom(origpool, (char *) newxml, origvol, flags);
+
+ if (newvol != NULL) {
+ vshPrint(ctl, _("Vol %s cloned from %s\n"),
+ virStorageVolGetName(newvol), virStorageVolGetName(origvol));
+ } else {
+ vshError(ctl, _("Failed to clone vol from %s"),
+ virStorageVolGetName(origvol));
+ goto cleanup;
+ }
+
+ if (virStorageVolDelete(origvol, 0) == 0) {
+ vshPrint(ctl, _("Vol %s deleted\n"), origname);
+ } else {
+ vshError(ctl, _("Failed to delete vol %s"), origname);
+ goto cleanup;
+ }
+
+ ret = true;
+
+cleanup:
+ VIR_FREE(origxml);
+ xmlFree(newxml);
+ if (origvol)
+ virStorageVolFree(origvol);
+ if (newvol)
+ virStorageVolFree(newvol);
+ if (origpool)
+ virStoragePoolFree(origpool);
+ return ret;
+}
+
+/*
* "vol-clone" command
*/
static const vshCmdInfo info_vol_clone[] = {
@@ -1752,6 +1849,12 @@ cmdVolPath(vshControl *ctl, const vshCmd *cmd)
}
const vshCmdDef storageVolCmds[] = {
+ {.name = "vol-rename",
+ .handler = cmdVolRename,
+ .opts = opts_vol_rename,
+ .info = info_vol_rename,
+ .flags = 0
+ },
{.name = "vol-clone",
.handler = cmdVolClone,
.opts = opts_vol_clone,
--
1.7.9.5
12 years
[libvirt] [PATCH] qemu: fix default spice password setting
by Ján Tomko
Set spice password even if default VNC password hasn't been set.
https://bugzilla.redhat.com/show_bug.cgi?id=953720
---
src/qemu/qemu_hotplug.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index a6c75cb..4f39ca4 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -2714,7 +2714,7 @@ qemuDomainChangeGraphicsPasswords(virQEMUDriverPtr driver,
int ret = -1;
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
- if (!auth->passwd && !cfg->vncPassword) {
+ if (!auth->passwd && !defaultPasswd) {
ret = 0;
goto cleanup;
}
--
1.8.1.5
12 years
[libvirt] [libvirt-php PATCH] Fixed the libvirt_domain_disk_add and libvirt_domain_disk_remove so that they can handle block devices, and can update a running domain
by Martijn Otto
---
src/libvirt-php.c | 246 +++++++++++++++++++++++++----------------------------
1 file changed, 114 insertions(+), 132 deletions(-)
diff --git a/src/libvirt-php.c b/src/libvirt-php.c
index 0b8345a..24e8606 100644
--- a/src/libvirt-php.c
+++ b/src/libvirt-php.c
@@ -4232,11 +4232,12 @@ PHP_FUNCTION(libvirt_domain_change_boot_devices)
Since version: 0.4.2
Description: Function is used to add the disk to the virtual machine using set of API functions to make it as simple as possible for the user
Arguments: @res [resource]: libvirt domain resource
- @img [string]: string for the image file on the host system
+ @path [string]: string for the image file or device node on the system
@dev [string]: string for the device to be presented to the guest (e.g. hda)
@typ [string]: bus type for the device in the guest, usually 'ide' or 'scsi'
- @driver [string]: driver type to be specified, like 'raw' or 'qcow2'
- @flags [int]: flags for getting the XML description
+ @driver [string]: driver type to be specified, like 'raw' or 'qcow2'
+ @cache [string]: cache mode, can be 'default', 'none', 'writeback' or 'writethrough'
+ @io [string]: io mode, can be 'default', 'native' or 'threads'
Returns: new domain resource
*/
PHP_FUNCTION(libvirt_domain_disk_add)
@@ -4244,46 +4245,40 @@ PHP_FUNCTION(libvirt_domain_disk_add)
php_libvirt_domain *domain=NULL;
zval *zdomain;
char *tmp1 = NULL;
- char *tmp2 = NULL;
char *xml;
- char *img = NULL;
- int img_len;
+ char *path = NULL;
+ int path_len;
char *dev = NULL;
int dev_len;
char *driver = NULL;
int driver_len;
char *typ = NULL;
int typ_len;
- char *new_xml = NULL;
- int new_len;
+ char *cache = "default";
+ int cache_len;
+ char *io = "default";
+ int io_len;
char new[4096] = { 0 };
- long xflags = 0;
int retval = -1;
- int pos = -1;
- php_libvirt_domain *res_domain = NULL;
- php_libvirt_connection *conn = NULL;
- virDomainPtr dom=NULL;
+ int block_device = 0; // whether the path leads to a block device (1) or to an image (0)
+ char cache_attr[32] = ""; // store the complete cache attribute, or an empty string to denote default
+ char io_attr[32] = ""; // store the complete io attribute, or an empty string to denote default
- GET_DOMAIN_FROM_ARGS("rssss|l",&zdomain,&img,&img_len,&dev,&dev_len,&typ,&typ_len,&driver,&driver_len,&xflags);
+ GET_DOMAIN_FROM_ARGS("rssss|ss",&zdomain,&path,&path_len,&dev,&dev_len,&typ,&typ_len,&driver,&driver_len,&cache,&cache_len,&io,&io_len);
- DPRINTF("%s: Domain %p, device = %s, image = %s, type = %s, driver = %s\n", PHPFUNC,
- domain->domain, dev, img, typ, driver);
+ DPRINTF("%s: Domain %p, device = %s, path = %s, type = %s, driver = %s, cache = %s, io = %s\n", PHPFUNC,
+ domain->domain, dev, path, typ, driver, cache, io);
- xml=virDomainGetXMLDesc(domain->domain,xflags);
+ // check whether the path leads to a block device
+ if (strncmp(path, "/dev/", 5) == 0)
+ block_device = 1;
+
+ xml=virDomainGetXMLDesc(domain->domain, 0);
if (xml==NULL) {
set_error_if_unset("Cannot get the XML description" TSRMLS_CC);
RETURN_FALSE;
}
- snprintf(new, sizeof(new), "//domain/devices/disk/source[@file=\"%s\"]/./@file", img);
- tmp1 = get_string_from_xpath(xml, new, NULL, &retval);
- if (tmp1 != NULL) {
- free(tmp1);
- snprintf(new, sizeof(new), "Domain already has image <i>%s</i> connected", img);
- set_error(new TSRMLS_CC);
- RETURN_FALSE;
- }
-
snprintf(new, sizeof(new), "//domain/devices/disk/target[@dev='%s']/./@dev", dev);
tmp1 = get_string_from_xpath(xml, new, NULL, &retval);
if (tmp1 != NULL) {
@@ -4293,58 +4288,72 @@ PHP_FUNCTION(libvirt_domain_disk_add)
RETURN_FALSE;
}
- if (access(img, R_OK) != 0) {
- snprintf(new, sizeof(new), "Image file <i>%s</i> doesn't exist", img);
- set_error(new TSRMLS_CC);
- RETURN_FALSE;
- }
-
- snprintf(new, sizeof(new),
- " <disk type='file' device='disk'>\n"
- " <driver name='qemu' type='%s'/>\n"
- " <source file='%s'/>\n"
- " <target dev='%s' bus='%s'/>\n"
- " </disk>", driver, img, dev, typ);
- tmp1 = strstr(xml, "</emulator>") + strlen("</emulator>");
- pos = strlen(xml) - strlen(tmp1);
+ // do we want to use a non-default cache mode?
+ if (strncmp(cache, "default", 7) != 0)
+ snprintf(cache_attr, sizeof(cache_attr), "cache='%s'", cache);
- tmp2 = emalloc( ( pos + 1 )* sizeof(char) );
- memset(tmp2, 0, pos + 1);
- memcpy(tmp2, xml, pos);
+ // or a non-default io mode perhaps?
+ if (strncmp(io, "default", 7) != 0)
+ snprintf(io_attr, sizeof(io_attr), "io='%s'", io);
- new_len = strlen(tmp1) + strlen(tmp2) + strlen(new) + 2;
- new_xml = emalloc( new_len * sizeof(char) );
- snprintf(new_xml, new_len, "%s\n%s%s", tmp2, new, tmp1);
-
- conn = domain->conn;
+ // check for valid image file or device node
+ if (block_device == 0) {
+ // check whether the image already appears in the xml
+ snprintf(new, sizeof(new), "//domain/devices/disk/source[@file=\"%s\"]/./@file", path);
+ tmp1 = get_string_from_xpath(xml, new, NULL, &retval);
+ if (tmp1 != NULL) {
+ free(tmp1);
+ snprintf(new, sizeof(new), "Domain already has image <i>%s</i> connected", path);
+ set_error(new TSRMLS_CC);
+ RETURN_FALSE;
+ }
- virDomainUndefine(domain->domain);
- virDomainFree(domain->domain);
+ if (access(path, R_OK) != 0) {
+ snprintf(new, sizeof(new), "Image file <i>%s</i> doesn't exist", path);
+ set_error(new TSRMLS_CC);
+ RETURN_FALSE;
+ }
- retval = virDomainFree(domain->domain);
- if (retval != 0) {
- DPRINTF("%s: Cannot free domain %p, error code = %d (%s)\n", PHPFUNC, domain->domain, retval, LIBVIRT_G(last_error));
- }
+ // create the xml to add the device
+ snprintf(new, sizeof(new),
+ " <disk type='file' device='disk'>\n"
+ " <driver name='qemu' type='%s' %s %s/>\n"
+ " <source file='%s'/>\n"
+ " <target dev='%s' bus='%s'/>\n"
+ " </disk>", driver, cache_attr, io_attr, path, dev, typ);
+ }
else {
- resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, domain->domain, 0 TSRMLS_CC);
- DPRINTF("%s: Domain %p freed\n", PHPFUNC, domain->domain);
- }
-
- dom=virDomainDefineXML(conn->conn, new_xml);
- if (dom==NULL) {
- DPRINTF("%s: Function failed, restoring original XML\n", PHPFUNC);
- dom=virDomainDefineXML(conn->conn, xml);
- if (dom == NULL)
+ // check whether the device already appears in the xml
+ snprintf(new, sizeof(new), "//domain/devices/disk/source[@dev=\"%s\"]/./@dev", path);
+ tmp1 = get_string_from_xpath(xml, new, NULL, &retval);
+ if (tmp1 != NULL) {
+ free(tmp1);
+ snprintf(new, sizeof(new), "Domain already has device <i>%s</i> connected", path);
+ set_error(new TSRMLS_CC);
RETURN_FALSE;
+ }
+
+ // create the xml to add the device
+ snprintf(new, sizeof(new),
+ " <disk type='block' device='disk'>\n"
+ " <driver name='qemu' type='%s' %s %s/>\n"
+ " <source dev='%s'/>\n"
+ " <target dev='%s' bus='%s'/>\n"
+ " </disk>", driver, cache_attr, io_attr, path, dev, typ);
}
- res_domain = emalloc(sizeof(php_libvirt_domain));
- res_domain->domain = dom;
- res_domain->conn = conn;
+ // attach the disk to the domain
+ retval = virDomainAttachDeviceFlags(domain->domain, new, VIR_DOMAIN_AFFECT_CURRENT);
+ if (retval != 0) {
+ snprintf(new, sizeof(new), "%s: Cannot add device to domain %p, error code = %d (%s)\n", PHPFUNC, domain->domain, retval, LIBVIRT_G(last_error));
+ set_error(new TSRMLS_CC);
+ RETURN_FALSE;
+ }
- DPRINTF("%s: returning %p\n", PHPFUNC, res_domain->domain);
- resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, res_domain->domain, 1 TSRMLS_CC);
- ZEND_REGISTER_RESOURCE(return_value, res_domain, le_libvirt_domain);
+ // the disk was successfully added
+ DPRINTF("%s: returning %p\n", PHPFUNC, domain->domain);
+ zend_list_addref(Z_LVAL_P(zdomain));
+ RETURN_RESOURCE(Z_LVAL_P(zdomain));
}
/*
@@ -4360,96 +4369,69 @@ PHP_FUNCTION(libvirt_domain_disk_remove)
{
php_libvirt_domain *domain=NULL;
zval *zdomain;
- char *tmp1 = NULL;
- char *tmp2 = NULL;
+ char *type = NULL;
+ char *path = NULL;
+ char *source = NULL;
char *xml;
char *dev = NULL;
int dev_len;
char *new_xml = NULL;
int new_len;
char new[4096] = { 0 };
- long xflags = 0;
int retval = -1;
- int pos = -1;
- int i, idx = 0;
- php_libvirt_domain *res_domain=NULL;
- php_libvirt_connection *conn = NULL;
- virDomainPtr dom = NULL;
- GET_DOMAIN_FROM_ARGS("rs|l",&zdomain,&dev,&dev_len,&xflags);
+ GET_DOMAIN_FROM_ARGS("rs|l",&zdomain,&dev,&dev_len);
DPRINTF("%s: Trying to remove %s from domain %p\n", PHPFUNC, dev, domain->domain);
- xml=virDomainGetXMLDesc(domain->domain,xflags);
+ xml=virDomainGetXMLDesc(domain->domain, 0);
if (xml==NULL) {
set_error_if_unset("Cannot get the XML description" TSRMLS_CC);
RETURN_FALSE;
}
- snprintf(new, sizeof(new), "//domain/devices/disk/target[@dev='%s']/./@dev", dev);
- tmp1 = get_string_from_xpath(xml, new, NULL, &retval);
- if (tmp1 == NULL) {
+ // check for the type, if no result is found, the disk does not exist
+ snprintf(new, sizeof(new), "//domain/devices/disk/target[@dev='%s']/../@type", dev);
+ type = get_string_from_xpath(xml, new, NULL, &retval);
+ if (type == NULL) {
snprintf(new, sizeof(new), "Device <i>%s</i> is not connected to the guest", dev);
set_error(new TSRMLS_CC);
RETURN_FALSE;
}
- free(tmp1);
-
- snprintf(new, sizeof(new), "<target dev='%s'", dev);
- tmp1 = strstr(xml, new) + strlen(new);
- pos = strlen(xml) - strlen(tmp1);
-
- tmp2 = emalloc( ( pos + 1 )* sizeof(char) );
- memset(tmp2, 0, pos + 1);
- memcpy(tmp2, xml, pos);
-
- for (i = strlen(tmp2) - 5; i > 0; i--)
- if ((tmp2[i] == '<') && (tmp2[i+1] == 'd')
- && (tmp2[i+2] == 'i') && (tmp2[i+3] == 's')
- && (tmp2[i+4] == 'k')) {
- tmp2[i-5] = 0;
- break;
- }
+ // are we dealing with a file or a block device?
+ if (strcmp(type, "file") == 0)
+ source = "file";
+ else
+ source = "dev";
- for (i = 0; i < strlen(tmp1) - 7; i++)
- if ((tmp1[i] == '<') && (tmp1[i+1] == '/')
- && (tmp1[i+2] == 'd') && (tmp1[i+3] == 'i')
- && (tmp1[i+4] == 's') && (tmp1[i+5] == 'k')
- && (tmp1[i+6] == '>')) {
- idx = i + 6;
- break;
- }
+ // retrieve the device or file
+ snprintf(new, sizeof(new), "//domain/devices/disk/target[@dev='%s']/../source/@%s", dev, source);
+ path = get_string_from_xpath(xml, new, NULL, &retval);
- new_len = strlen(tmp2) + (strlen(tmp1) - idx);
- new_xml = emalloc( new_len * sizeof(char) );
- memset(new_xml, 0, new_len);
- strcpy(new_xml, tmp2);
- for (i = idx; i < strlen(tmp1) - 1; i++)
- new_xml[ strlen(tmp2) + i - idx ] = tmp1[i];
+ // define the xml to remove the device
+ snprintf(new, sizeof(new),
+ " <disk type='%s' device='disk'>"
+ " <source %s='%s'/>"
+ " <target dev='%s'/>"
+ " </disk>", type, source, path, dev);
- conn = domain->conn;
- virDomainUndefine(domain->domain);
+ // cleanup temporary resources
+ free(type);
+ free(path);
- retval = virDomainFree(domain->domain);
+ // remove the disk from the domain
+ retval = virDomainDetachDeviceFlags(domain->domain, new, VIR_DOMAIN_AFFECT_CURRENT);
if (retval != 0) {
- DPRINTF("%s: Cannot free domain %p, error code = %d (%s)\n", PHPFUNC, domain->domain, retval, LIBVIRT_G(last_error));
- }
- else {
- resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, domain->domain, 0 TSRMLS_CC);
- DPRINTF("%s: Domain %p freed\n", PHPFUNC, domain->domain);
+ snprintf(new, sizeof(new), "%s: Cannot remove device from domain %p, error code = %d (%s)\n", PHPFUNC, domain->domain, retval, LIBVIRT_G(last_error));
+ set_error(new TSRMLS_CC);
+ RETURN_FALSE;
}
- dom=virDomainDefineXML(conn->conn,new_xml);
- if (dom==NULL) RETURN_FALSE;
-
- res_domain = emalloc(sizeof(php_libvirt_domain));
- res_domain->domain = dom;
- res_domain->conn = conn;
-
- DPRINTF("%s: returning %p\n", PHPFUNC, res_domain->domain);
- resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, res_domain->domain, 1 TSRMLS_CC);
- ZEND_REGISTER_RESOURCE(return_value, res_domain, le_libvirt_domain);
+ // the disk was successfully removed
+ DPRINTF("%s: returning %p\n", PHPFUNC, domain->domain);
+ zend_list_addref(Z_LVAL_P(zdomain));
+ RETURN_RESOURCE(Z_LVAL_P(zdomain));
}
/*
@@ -5172,7 +5154,7 @@ PHP_FUNCTION(libvirt_domain_get_block_info) {
GET_DOMAIN_FROM_ARGS("rs",&zdomain,&dev,&dev_len);
/* Get XML for the domain */
- xml=virDomainGetXMLDesc(domain->domain, VIR_DOMAIN_XML_INACTIVE);
+ xml=virDomainGetXMLDesc(domain->domain, 0);
if (xml==NULL) {
set_error("Cannot get domain XML" TSRMLS_CC);
RETURN_FALSE;
--
1.7.9.5
12 years