[libvirt] [libvirt-designer] Add GvirDesignerDomain::osinfo-db
by Christophe Fergeau
virtxml was doing its own loading of the libosinfo database,
and gvir_designer_init() was loading it a second time.
By adding a GVirDesignerDomain::osinfo_db property, applications
can share the same OsinfoDb as libvirt-designer. The association
is made per libvirt-designer domain for more flexibility.
---
examples/virtxml.c | 2 +-
libvirt-designer/libvirt-designer-domain.c | 34 ++++++++++++++++++++++++++--
libvirt-designer/libvirt-designer-domain.h | 3 ++-
libvirt-designer/libvirt-designer-internal.h | 3 ---
libvirt-designer/libvirt-designer-main.c | 12 ----------
libvirt-designer/libvirt-designer-main.h | 2 ++
6 files changed, 37 insertions(+), 19 deletions(-)
diff --git a/examples/virtxml.c b/examples/virtxml.c
index a68843d..c5a5e24 100644
--- a/examples/virtxml.c
+++ b/examples/virtxml.c
@@ -558,7 +558,7 @@ main(int argc, char *argv[])
goto cleanup;
}
- domain = gvir_designer_domain_new(os, platform, caps);
+ domain = gvir_designer_domain_new(db, os, platform, caps);
gvir_designer_domain_setup_machine(domain, &error);
CHECK_ERROR;
diff --git a/libvirt-designer/libvirt-designer-domain.c b/libvirt-designer/libvirt-designer-domain.c
index 3e31bd1..49e8068 100644
--- a/libvirt-designer/libvirt-designer-domain.c
+++ b/libvirt-designer/libvirt-designer-domain.c
@@ -35,6 +35,7 @@ struct _GVirDesignerDomainPrivate
{
GVirConfigDomain *config;
GVirConfigCapabilities *caps;
+ OsinfoDb *osinfo_db;
OsinfoOs *os;
OsinfoPlatform *platform;
@@ -66,6 +67,7 @@ enum {
PROP_OS,
PROP_PLATFORM,
PROP_CAPS,
+ PROP_OSINFO_DB,
};
static void gvir_designer_domain_get_property(GObject *object,
@@ -83,6 +85,10 @@ static void gvir_designer_domain_get_property(GObject *object,
g_value_set_object(value, priv->config);
break;
+ case PROP_OSINFO_DB:
+ g_value_set_object(value, priv->osinfo_db);
+ break;
+
case PROP_OS:
g_value_set_object(value, priv->os);
break;
@@ -112,6 +118,11 @@ static void gvir_designer_domain_set_property(GObject *object,
GVirDesignerDomainPrivate *priv = design->priv;
switch (prop_id) {
+ case PROP_OSINFO_DB:
+ if (priv->osinfo_db)
+ g_object_unref(priv->osinfo_db);
+ priv->osinfo_db = g_value_dup_object(value);
+ break;
case PROP_OS:
if (priv->os)
g_object_unref(priv->os);
@@ -147,6 +158,8 @@ static void gvir_designer_domain_finalize(GObject *object)
g_object_unref(priv->caps);
if (priv->deployment)
g_object_unref(priv->deployment);
+ if (priv->osinfo_db)
+ g_object_unref(priv->osinfo_db);
G_OBJECT_CLASS(gvir_designer_domain_parent_class)->finalize(object);
}
@@ -171,6 +184,16 @@ static void gvir_designer_domain_class_init(GVirDesignerDomainClass *klass)
G_PARAM_STATIC_STRINGS));
g_object_class_install_property(object_class,
+ PROP_OSINFO_DB,
+ g_param_spec_object("osinfo-db",
+ "Osinfo Database",
+ "libosinfo database",
+ OSINFO_TYPE_DB,
+ G_PARAM_READABLE |
+ G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property(object_class,
PROP_OS,
g_param_spec_object("os",
"Os",
@@ -215,11 +238,13 @@ static void gvir_designer_domain_init(GVirDesignerDomain *design)
}
-GVirDesignerDomain *gvir_designer_domain_new(OsinfoOs *os,
+GVirDesignerDomain *gvir_designer_domain_new(OsinfoDb *db,
+ OsinfoOs *os,
OsinfoPlatform *platform,
GVirConfigCapabilities *caps)
{
return GVIR_DESIGNER_DOMAIN(g_object_new(GVIR_DESIGNER_TYPE_DOMAIN,
+ "osinfo-db", db,
"os", os,
"platform", platform,
"capabilities", caps,
@@ -721,7 +746,12 @@ gvir_designer_domain_get_preferred_device(GVirDesignerDomain *design,
OsinfoDeviceLink *dev_link = NULL;
if (!deployment) {
- priv->deployment = deployment = osinfo_db_find_deployment(osinfo_db,
+ if (!priv->osinfo_db) {
+ g_set_error(error, GVIR_DESIGNER_DOMAIN_ERROR, 0,
+ "Unable to find any deployment in libosinfo database");
+ goto cleanup;
+ }
+ priv->deployment = deployment = osinfo_db_find_deployment(priv->osinfo_db,
priv->os,
priv->platform);
if (!deployment) {
diff --git a/libvirt-designer/libvirt-designer-domain.h b/libvirt-designer/libvirt-designer-domain.h
index 38731a2..4d68ff6 100644
--- a/libvirt-designer/libvirt-designer-domain.h
+++ b/libvirt-designer/libvirt-designer-domain.h
@@ -66,7 +66,8 @@ struct _GVirDesignerDomainClass
GType gvir_designer_domain_get_type(void);
-GVirDesignerDomain *gvir_designer_domain_new(OsinfoOs *os,
+GVirDesignerDomain *gvir_designer_domain_new(OsinfoDb *osinfo_db,
+ OsinfoOs *os,
OsinfoPlatform *platform,
GVirConfigCapabilities *caps);
diff --git a/libvirt-designer/libvirt-designer-internal.h b/libvirt-designer/libvirt-designer-internal.h
index bbef922..e95edfc 100644
--- a/libvirt-designer/libvirt-designer-internal.h
+++ b/libvirt-designer/libvirt-designer-internal.h
@@ -24,7 +24,4 @@
#ifndef __LIBVIRT_DESIGNER_INTERNAL_H__
#define __LIBVIRT_DESIGNER_INTERNAL_H__
-extern OsinfoLoader *osinfo_loader;
-extern OsinfoDb *osinfo_db;
-
#endif /* __LIBVIRT_DESIGNER_INTERNAL_H__ */
diff --git a/libvirt-designer/libvirt-designer-main.c b/libvirt-designer/libvirt-designer-main.c
index 5c70b57..927eb21 100644
--- a/libvirt-designer/libvirt-designer-main.c
+++ b/libvirt-designer/libvirt-designer-main.c
@@ -30,9 +30,6 @@
#include <libvirt-designer/libvirt-designer.h>
#include <libvirt-gconfig/libvirt-gconfig.h>
-OsinfoLoader *osinfo_loader = NULL;
-OsinfoDb *osinfo_db = NULL;
-
/**
* gvir_designer_init:
* @argc: (inout): pointer to application's argc
@@ -57,7 +54,6 @@ static void gvir_log_handler(const gchar *log_domain G_GNUC_UNUSED,
fprintf(stderr, "%s\n", message);
}
-
/**
* gvir_designer_init_check:
* @argc: (inout): pointer to application's argc
@@ -85,13 +81,5 @@ gboolean gvir_designer_init_check(int *argc,
gvir_log_handler, NULL);
#endif
- /* Init libosinfo and load databases from default paths */
- /* XXX maybe we want to let users tell a different path via
- * env variable or argv */
- osinfo_loader = osinfo_loader_new();
- osinfo_loader_process_default_path(osinfo_loader, NULL);
-
- osinfo_db = osinfo_loader_get_db(osinfo_loader);
-
return TRUE;
}
diff --git a/libvirt-designer/libvirt-designer-main.h b/libvirt-designer/libvirt-designer-main.h
index 2500ef7..5e82f8a 100644
--- a/libvirt-designer/libvirt-designer-main.h
+++ b/libvirt-designer/libvirt-designer-main.h
@@ -24,6 +24,8 @@
#error "Only <libvirt-gdesigner/libvirt-gdesigner.h> can be included directly."
#endif
+#include <osinfo/osinfo.h>
+
#ifndef __LIBVIRT_DESIGNER_MAIN_H__
#define __LIBVIRT_DESIGNER_MAIN_H__
--
1.8.1.4
11 years, 9 months
[libvirt] Cannot initialize thread local for current identity
by Gao feng
When I play with the latest libvirt,my libvirtd force me out of console of domain.
I find the problem is introduced by commit ebf78be4c277cffae57d99daa199a9b3c1cf9804
"Set the current client identity during API call dispatch".
Below is the error message
Error polling connection 'qemu:///system': Cannot initialize thread local for current identity.
I don't know if there are something wrong with my configuration, But when I reset to
the commit id before this commit, everything runs well.
If you need some debug information, Please let me know,It's my pleasure.
Thanks.
11 years, 9 months
[libvirt] [PATCH] python:remove semicolon in python code
by Guannan Ren
This breaked "make syntax-check" testing
Pushed under trivial rule
---
python/generator.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/python/generator.py b/python/generator.py
index fbaf797..0237374 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -1490,7 +1490,7 @@ def buildWrappers(module):
classes.write(", %s" % arg[0])
n = n + 1
if arg[0] == "flags":
- classes.write("=0");
+ classes.write("=0")
classes.write("):\n")
writeDoc(module, name, args, ' ', classes)
n = 0
--
1.7.11.2
11 years, 9 months
[libvirt] [PATCH] qemu: add support for LSI MegaRAID SAS1078 (aka megasas) SCSI controller
by Paolo Bonzini
This does nothing more than adding the new device and capability.
The device is present since QEMU 1.2.0.
Signed-off-by: Paolo Bonzini <pbonzini(a)redhat.com>
---
docs/formatdomain.html.in | 6 ++--
docs/schemas/domaincommon.rng | 1 +
src/conf/domain_conf.c | 3 +-
src/conf/domain_conf.h | 1 +
src/qemu/qemu_capabilities.c | 2 ++
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 13 ++++++++-
src/vmx/vmx.c | 3 +-
tests/qemuhelptest.c | 6 ++--
.../qemuxml2argv-disk-scsi-megasas.args | 9 ++++++
.../qemuxml2argv-disk-scsi-megasas.xml | 32 ++++++++++++++++++++++
tests/qemuxml2argvtest.c | 3 ++
tests/qemuxml2xmltest.c | 1 +
13 files changed, 73 insertions(+), 8 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-megasas.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-megasas.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index c2cf75f..8bf0736 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2091,9 +2091,9 @@
control how many devices can be connected through the
controller. A "scsi" controller has an optional
attribute <code>model</code>, which is one of "auto", "buslogic",
- "ibmvscsi", "lsilogic", "lsias1068", "virtio-scsi" or "vmpvscsi".
- A "usb" controller has an optional attribute <code>model</code>,
- which is one of "piix3-uhci", "piix4-uhci", "ehci",
+ "ibmvscsi", "lsilogic", "lsisas1068", "lsisas1078", "virtio-scsi" or
+ "vmpvscsi". A "usb" controller has an optional attribute
+ <code>model</code>, which is one of "piix3-uhci", "piix4-uhci", "ehci",
"ich9-ehci1", "ich9-uhci1", "ich9-uhci2", "ich9-uhci3",
"vt82c686b-uhci", "pci-ohci" or "nec-xhci". Additionally,
<span class="since">since 0.10.0</span>, if the USB bus needs to be
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index fae5c0d..a136ae8 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1391,6 +1391,7 @@
<value>vmpvscsi</value>
<value>ibmvscsi</value>
<value>virtio-scsi</value>
+ <value>lsisas1078</value>
<value>piix3-uhci</value>
<value>piix4-uhci</value>
<value>ehci</value>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 159a23d..0ef67be 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -304,7 +304,8 @@ VIR_ENUM_IMPL(virDomainControllerModelSCSI, VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAS
"lsisas1068",
"vmpvscsi",
"ibmvscsi",
- "virtio-scsi");
+ "virtio-scsi",
+ "lsisas1078");
VIR_ENUM_IMPL(virDomainControllerModelUSB, VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST,
"piix3-uhci",
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index a750a1f..c3b2608 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -695,6 +695,7 @@ enum virDomainControllerModelSCSI {
VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VMPVSCSI,
VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI,
VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI,
+ VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1078,
VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST
};
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 50f8084..3840b41 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -212,6 +212,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
"rng-egd",
"virtio-ccw",
"dtb",
+ "megasas",
);
struct _virQEMUCaps {
@@ -1329,6 +1330,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
{ "virtio-scsi-pci", QEMU_CAPS_VIRTIO_SCSI },
{ "virtio-scsi-s390", QEMU_CAPS_VIRTIO_SCSI },
{ "virtio-scsi-ccw", QEMU_CAPS_VIRTIO_SCSI },
+ { "megasas", QEMU_CAPS_SCSI_MEGASAS },
{ "spicevmc", QEMU_CAPS_DEVICE_SPICEVMC },
{ "qxl-vga", QEMU_CAPS_DEVICE_QXL_VGA },
{ "qxl", QEMU_CAPS_DEVICE_QXL },
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index b0f8c5b..7101f67 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -173,6 +173,7 @@ enum virQEMUCapsFlags {
QEMU_CAPS_OBJECT_RNG_EGD = 131, /* EGD protocol daemon for rng */
QEMU_CAPS_VIRTIO_CCW = 132, /* -device virtio-*-ccw */
QEMU_CAPS_DTB = 133, /* -dtb file */
+ QEMU_CAPS_SCSI_MEGASAS = 134, /* -device megasas */
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 006f83d..a0c278f 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -500,7 +500,7 @@ qemuSetScsiControllerModel(virDomainDefPtr def,
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_LSI)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("This QEMU doesn't support "
- "lsi scsi controller"));
+ "the LSI 53C895A SCSI controller"));
return -1;
}
break;
@@ -515,6 +515,14 @@ qemuSetScsiControllerModel(virDomainDefPtr def,
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI:
/*TODO: need checking work here if necessary */
break;
+ case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1078:
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_MEGASAS)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("This QEMU doesn't support "
+ "the LSI SAS1078 controller"));
+ return -1;
+ }
+ break;
default:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unsupported controller model: %s"),
@@ -3544,6 +3552,9 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef,
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI:
virBufferAddLit(&buf, "spapr-vscsi");
break;
+ case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1078:
+ virBufferAddLit(&buf, "megasas");
+ break;
default:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unsupported controller model: %s"),
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index c604bd2..d7eee09 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -511,7 +511,8 @@ VIR_ENUM_IMPL(virVMXControllerModelSCSI, VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST,
"lsisas1068",
"pvscsi",
"UNUSED ibmvscsi",
- "UNUSED virtio-scsi");
+ "UNUSED virtio-scsi",
+ "UNUSED lsisas1078");
diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c
index 059fa86..a28109a 100644
--- a/tests/qemuhelptest.c
+++ b/tests/qemuhelptest.c
@@ -912,7 +912,8 @@ mymain(void)
QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
QEMU_CAPS_DEVICE_USB_SERIAL,
QEMU_CAPS_DEVICE_USB_NET,
- QEMU_CAPS_DTB);
+ QEMU_CAPS_DTB,
+ QEMU_CAPS_SCSI_MEGASAS);
DO_TEST("qemu-kvm-1.2.0", 1002000, 1, 0,
QEMU_CAPS_VNC_COLON,
QEMU_CAPS_NO_REBOOT,
@@ -1017,7 +1018,8 @@ mymain(void)
QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
QEMU_CAPS_DEVICE_USB_SERIAL,
QEMU_CAPS_DEVICE_USB_NET,
- QEMU_CAPS_DTB);
+ QEMU_CAPS_DTB,
+ QEMU_CAPS_SCSI_MEGASAS);
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-megasas.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-megasas.args
new file mode 100644
index 0000000..c4d5f87
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-megasas.args
@@ -0,0 +1,9 @@
+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 \
+megasas,id=scsi0,bus=pci.0,addr=0x3 -usb -drive file=/dev/HostVG/QEMUGuest1,\
+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=/tmp/scsidisk.img,if=none,\
+id=drive-scsi0-0-4-0 -device scsi-disk,bus=scsi0.0,channel=0,scsi-id=4,lun=0,\
+drive=drive-scsi0-0-4-0,id=scsi0-0-4-0 -device virtio-balloon-pci,\
+id=balloon0,bus=pci.0,addr=0x4
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-megasas.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-megasas.xml
new file mode 100644
index 0000000..9a496ae
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-megasas.xml
@@ -0,0 +1,32 @@
+<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='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <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/scsidisk.img'/>
+ <target dev='sda' bus='scsi'/>
+ <address type='drive' controller='0' bus='0' target='4' unit='0'/>
+ </disk>
+ <controller type='ide' index='0'/>
+ <controller type='scsi' index='0' model='lsisas1078'/>
+ <controller type='usb' index='0'/>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 5e7adf5..38787ac 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -550,6 +550,9 @@ mymain(void)
DO_TEST("disk-scsi-virtio-scsi",
QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
QEMU_CAPS_VIRTIO_SCSI);
+ DO_TEST("disk-scsi-megasas",
+ QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
+ QEMU_CAPS_SCSI_MEGASAS);
DO_TEST("disk-sata-device",
QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE,
QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_ICH9_AHCI);
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 899414d..ba9aa96 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -179,6 +179,7 @@ mymain(void)
DO_TEST("disk-scsi-device");
DO_TEST("disk-scsi-vscsi");
DO_TEST("disk-scsi-virtio-scsi");
+ DO_TEST("disk-scsi-megasas");
DO_TEST_FULL("disk-mirror", false, WHEN_ACTIVE);
DO_TEST_FULL("disk-mirror", true, WHEN_INACTIVE);
DO_TEST("graphics-listen-network");
--
1.8.1.4
11 years, 9 months
[libvirt] [PATCH v2 0/6] libvirt support for userspace iSCSI initiator (libiscsi)
by Paolo Bonzini
This series adds support for the libiscsi userspace initiator.
Compared to v1, logical units are now specified with IQN/LUN
syntax in the name attribute.
Paolo
Paolo Bonzini (6):
qemu: add support for libiscsi
qemu: support passthrough for iscsi disks
domain: make port optional for network disks
secret: add iscsi to possible usage types
domain: parse XML for iscsi authorization credentials
qemu: pass iscsi authorization credentials
docs/formatdomain.html.in | 29 +++--
docs/formatsecret.html.in | 12 ++
docs/schemas/domaincommon.rng | 9 +-
docs/schemas/secret.rng | 10 ++
include/libvirt/libvirt.h.in | 1 +
src/conf/domain_conf.c | 38 ++++--
src/conf/secret_conf.c | 22 +++-
src/conf/secret_conf.h | 1 +
src/libvirt_private.syms | 1 +
src/qemu/qemu_command.c | 143 +++++++++++++++++++--
src/secret/secret_driver.c | 8 ++
tests/qemuargv2xmltest.c | 1 +
.../qemuxml2argv-disk-drive-network-gluster.args | 2 +-
...qemuxml2argv-disk-drive-network-iscsi-auth.args | 1 +
.../qemuxml2argv-disk-drive-network-iscsi-auth.xml | 31 +++++
.../qemuxml2argv-disk-drive-network-iscsi-lun.args | 1 +
.../qemuxml2argv-disk-drive-network-iscsi-lun.xml | 28 ++++
.../qemuxml2argv-disk-drive-network-iscsi.args | 1 +
.../qemuxml2argv-disk-drive-network-iscsi.xml | 7 +
...ml2argv-disk-drive-network-nbd-ipv6-export.args | 2 +-
.../qemuxml2argv-disk-drive-network-nbd-ipv6.args | 2 +-
tests/qemuxml2argvtest.c | 8 ++
tests/qemuxml2xmltest.c | 1 +
23 files changed, 315 insertions(+), 44 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi-auth.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi-auth.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi-lun.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi-lun.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi.args
--
1.8.1.4
11 years, 9 months
[libvirt] [PATCH] Link libvirt_util with numa library
by prasadjoshi.linux@gmail.com
From: Prasad Joshi <prasadjoshi.linux(a)gmail.com>
When the libvirt is configured with numactl, the virt-aa-helper
compilation fails with following errors
CCLD virt-aa-helper
libvirt_util.a(...): In function `virNumaSetupMemoryPolicy':
virnuma.c:109: undefined reference to `numa_available'
virnuma.c:115: undefined reference to `numa_max_node'
libvirt_util.a(libvirt_util_la-virnuma.o): .. `nodemask_zero_compat':
/usr/include/numa.h:80: undefined reference to `numa_bitmask_clearall'
/libvirt_util.a(libvirt_util_la-virnuma.o): `virNumaSetupMemoryPolicy':
virnuma.c:136: undefined reference to `numa_set_bind_policy'
libvirt_util.a(libvirt_util_la-virnuma.o): `numa_set_membind_compat':
/usr/include/numa.h:360: undefined reference to `numa_set_membind'
libvirt_util.a(libvirt_util_la-virnuma.o): `virNumaSetupMemoryPolicy':
virnuma.c:138: undefined reference to `numa_set_bind_policy'
libvirt_util.a(): `numa_set_interleave_mask_compat':
/usr/include/numa.h:330: undefined reference to `numa_set_interleave_mask'
libvirt_util.a(libvirt_util_la-virnuma.o): `virNumaSetupMemoryPolicy':
virnuma.c:155: undefined reference to `numa_set_bind_policy'
virnuma.c:156: undefined reference to `numa_set_preferred'
collect2: error: ld returned 1 exit status
make[3]: *** [virt-aa-helper] Error 1
make[3]: Leaving directory `/home/prasad/KVM/libvirt/src'
The patch fixes this problem by adding numa library to the list of
libraries to be linked with libvirt_util
Signed-off-by: Prasad Joshi <prasadjoshi.linux(a)gmail.com>
---
src/Makefile.am | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 21f8882..5e8e062 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -772,7 +772,7 @@ libvirt_util_la_CFLAGS = $(CAPNG_CFLAGS) $(YAJL_CFLAGS) $(LIBNL_CFLAGS) \
libvirt_util_la_LIBADD = $(CAPNG_LIBS) $(YAJL_LIBS) $(LIBNL_LIBS) \
$(THREAD_LIBS) $(AUDIT_LIBS) $(DEVMAPPER_LIBS) \
$(LIB_CLOCK_GETTIME) $(DBUS_LIBS) $(MSCOM_LIBS) $(LIBXML_LIBS) \
- $(SECDRIVER_LIBS)
+ $(SECDRIVER_LIBS) $(NUMACTL_LIBS)
noinst_LTLIBRARIES += libvirt_conf.la
--
1.7.10.4
11 years, 9 months
[libvirt] [PATCH 1/2] python: treat flags as default argument with value 0
by Guannan Ren
The following four functions have not changed because default arguments
have to come after positional arguments. Changing them will break the
the binding APIs.
migrate(self, dconn, flags, dname, uri, bandwidth):
migrate2(self, dconn, dxml, flags, dname, uri, bandwidth):
migrateToURI(self, duri, flags, dname, bandwidth):
migrateToURI2(self, dconnuri, miguri, dxml, flags, dname, bandwidth):
---
python/generator.py | 2 ++
python/libvirt-override-virConnect.py | 14 +++++++-------
python/libvirt-override-virDomain.py | 2 +-
python/libvirt-override-virDomainSnapshot.py | 2 +-
python/libvirt-override-virStoragePool.py | 2 +-
python/libvirt-override.py | 2 +-
6 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/python/generator.py b/python/generator.py
index d269e88..bb53fcf 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -1487,6 +1487,8 @@ def buildWrappers(module):
if n != index:
classes.write(", %s" % arg[0])
n = n + 1
+ if arg[0] == "flags":
+ classes.write("=0");
classes.write("):\n")
writeDoc(module, name, args, ' ', classes)
n = 0
diff --git a/python/libvirt-override-virConnect.py b/python/libvirt-override-virConnect.py
index 121ef6f..5495b70 100644
--- a/python/libvirt-override-virConnect.py
+++ b/python/libvirt-override-virConnect.py
@@ -204,7 +204,7 @@
self.domainEventCallbackID[ret] = opaque
return ret
- def listAllDomains(self, flags):
+ def listAllDomains(self, flags=0):
"""List all domains and returns a list of domain objects"""
ret = libvirtmod.virConnectListAllDomains(self._o, flags)
if ret is None:
@@ -216,7 +216,7 @@
return retlist
- def listAllStoragePools(self, flags):
+ def listAllStoragePools(self, flags=0):
"""Returns a list of storage pool objects"""
ret = libvirtmod.virConnectListAllStoragePools(self._o, flags)
if ret is None:
@@ -228,7 +228,7 @@
return retlist
- def listAllNetworks(self, flags):
+ def listAllNetworks(self, flags=0):
"""Returns a list of network objects"""
ret = libvirtmod.virConnectListAllNetworks(self._o, flags)
if ret is None:
@@ -240,7 +240,7 @@
return retlist
- def listAllInterfaces(self, flags):
+ def listAllInterfaces(self, flags=0):
"""Returns a list of interface objects"""
ret = libvirtmod.virConnectListAllInterfaces(self._o, flags)
if ret is None:
@@ -252,7 +252,7 @@
return retlist
- def listAllDevices(self, flags):
+ def listAllDevices(self, flags=0):
"""Returns a list of host node device objects"""
ret = libvirtmod.virConnectListAllNodeDevices(self._o, flags)
if ret is None:
@@ -264,7 +264,7 @@
return retlist
- def listAllNWFilters(self, flags):
+ def listAllNWFilters(self, flags=0):
"""Returns a list of network filter objects"""
ret = libvirtmod.virConnectListAllNWFilters(self._o, flags)
if ret is None:
@@ -276,7 +276,7 @@
return retlist
- def listAllSecrets(self, flags):
+ def listAllSecrets(self, flags=0):
"""Returns a list of secret objects"""
ret = libvirtmod.virConnectListAllSecrets(self._o, flags)
if ret is None:
diff --git a/python/libvirt-override-virDomain.py b/python/libvirt-override-virDomain.py
index ccc4d5f..142b1d4 100644
--- a/python/libvirt-override-virDomain.py
+++ b/python/libvirt-override-virDomain.py
@@ -1,4 +1,4 @@
- def listAllSnapshots(self, flags):
+ def listAllSnapshots(self, flags=0):
"""List all snapshots and returns a list of snapshot objects"""
ret = libvirtmod.virDomainListAllSnapshots(self._o, flags)
if ret is None:
diff --git a/python/libvirt-override-virDomainSnapshot.py b/python/libvirt-override-virDomainSnapshot.py
index bf708a5..ec53358 100644
--- a/python/libvirt-override-virDomainSnapshot.py
+++ b/python/libvirt-override-virDomainSnapshot.py
@@ -6,7 +6,7 @@
"""Get the domain that a snapshot was created for"""
return self.domain()
- def listAllChildren(self, flags):
+ def listAllChildren(self, flags=0):
"""List all child snapshots and returns a list of snapshot objects"""
ret = libvirtmod.virDomainSnapshotListAllChildren(self._o, flags)
if ret is None:
diff --git a/python/libvirt-override-virStoragePool.py b/python/libvirt-override-virStoragePool.py
index ffe160c..325e403 100644
--- a/python/libvirt-override-virStoragePool.py
+++ b/python/libvirt-override-virStoragePool.py
@@ -1,4 +1,4 @@
- def listAllVolumes(self, flags):
+ def listAllVolumes(self, flags=0):
"""List all storage volumes and returns a list of storage volume objects"""
ret = libvirtmod.virStoragePoolListAllVolumes(self._o, flags)
if ret is None:
diff --git a/python/libvirt-override.py b/python/libvirt-override.py
index 82d7dcb..ccfec48 100644
--- a/python/libvirt-override.py
+++ b/python/libvirt-override.py
@@ -85,7 +85,7 @@ def registerErrorHandler(f, ctx):
Returns 1 in case of success."""
return libvirtmod.virRegisterErrorHandler(f,ctx)
-def openAuth(uri, auth, flags):
+def openAuth(uri, auth, flags=0):
ret = libvirtmod.virConnectOpenAuth(uri, auth, flags)
if ret is None:raise libvirtError('virConnectOpenAuth() failed')
return virConnect(_obj=ret)
--
1.7.11.2
11 years, 9 months
[libvirt] [PATCH] nwfilter: probe for inverted ctdir
by Stefan Berger
Linux netfilter at some point inverted the meaning of the '--ctdir reply'
and newer netfilter implementations now expect '--ctdir original'
instread and vice-versa.
We probe for this netfilter change via a UDP message over loopback and 3
filtering rules applied to INPUT. If the sent byte arrives, the newer
netfilter implementation has been detected.
Signed-off-by: Stefan Berger <stefanb(a)linux.vnet.ibm.com>
---
src/nwfilter/nwfilter_ebiptables_driver.c | 123
++++++++++++++++++++++++++++++
1 file changed, 123 insertions(+)
Index: libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c
===================================================================
--- libvirt-acl.orig/src/nwfilter/nwfilter_ebiptables_driver.c
+++ libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c
@@ -27,6 +27,10 @@
#include <string.h>
#include <sys/stat.h>
#include <fcntl.h>
+#include <arpa/inet.h>
+#include <sys/select.h>
+#include <sys/time.h>
+#include <unistd.h>
#include "internal.h"
@@ -85,6 +89,12 @@ static char *iptables_cmd_path;
static char *ip6tables_cmd_path;
static char *grep_cmd_path;
+/*
+ * --ctdir original vs. reply's meaning was inverted in the netfilter
+ * at some point. We probe for it.
+ */
+static bool iptables_ctdir_corrected = false;
+
#define PRINT_ROOT_CHAIN(buf, prefix, ifname) \
snprintf(buf, sizeof(buf), "libvirt-%c-%s", prefix, ifname)
#define PRINT_CHAIN(buf, prefix, ifname, suffix) \
@@ -1262,6 +1272,9 @@ iptablesEnforceDirection(int directionIn
virNWFilterRuleDefPtr rule,
virBufferPtr buf)
{
+ if (iptables_ctdir_corrected)
+ directionIn = !directionIn;
+
if (rule->tt != VIR_NWFILTER_RULE_DIRECTION_INOUT)
virBufferAsprintf(buf, " -m conntrack --ctdir %s",
(directionIn) ? "Original"
@@ -4304,6 +4317,113 @@ ebiptablesDriverTestCLITools(void)
return ret;
}
+static void
+ebiptablesDriverProbeCtdir(void)
+{
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+ static const char cmdline[] =
+ "$IPT -%c INPUT %c -i lo -p udp --dport %hu "
+ "-m state --state ESTABLISHED -j ACCEPT " CMD_SEPARATOR
+ "$IPT -%c INPUT %c -i lo -p udp --dport %hu "
+ "-m conntrack --ctdir original -j ACCEPT " CMD_SEPARATOR
+ "$IPT -%c INPUT %c -i lo -p udp --dport %hu -j DROP";
+ /*
+ * Above '--ctdir original' gets this test to receive a message on
+ * 'fixed' netfilter.
+ */
+ unsigned short port;
+ int ssockfd = -1, csockfd = -1;
+ struct sockaddr_in serveraddr = {
+ .sin_family = AF_INET,
+ };
+ fd_set readfds;
+ struct timeval timeout = {
+ .tv_sec = 0,
+ .tv_usec = 1000 * 200,
+ };
+ int n;
+
+ if (inet_aton("127.0.0.1", &serveraddr.sin_addr) == 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ "inet_aton failed");
+ goto cleanup;
+ }
+
+ if ((ssockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0 ||
+ (csockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
+ VIR_ERROR(_("Could not open UDP socket"));
+ goto cleanup;
+ }
+
+ for (port = 0xffff; port > 1024; port--) {
+ serveraddr.sin_port = htons(port);
+ if (bind(ssockfd, (struct sockaddr *)&serveraddr,
+ sizeof(serveraddr)) == 0)
+ break;
+ }
+ if (port == 1024) {
+ VIR_ERROR(_("Could not bind to any UDP socket"));
+ goto cleanup;
+ }
+
+ NWFILTER_SET_IPTABLES_SHELLVAR(&buf);
+ virBufferAsprintf(&buf, cmdline,
+ 'I', '1', port,
+ 'I', '2', port,
+ 'I', '3', port);
+
+ if (virBufferError(&buf)) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ if (ebiptablesExecCLI(&buf, NULL, NULL) < 0) {
+ VIR_ERROR(_("Could not apply iptables rules"));
+ goto cleanup_iptables;
+ }
+
+ if (sendto(csockfd, cmdline, 1, 0, (struct sockaddr *)&serveraddr,
+ sizeof(serveraddr)) < 0) {
+ VIR_ERROR(_("Could not send to UDP socket"));
+ goto cleanup_iptables;
+ }
+
+ FD_ZERO(&readfds);
+ FD_SET(ssockfd, &readfds);
+
+ while (true) {
+ n = select(ssockfd + 1, &readfds, NULL, NULL, &timeout);
+ if (n < 0) {
+ if (errno == EINTR)
+ continue;
+ VIR_ERROR(_("Select failed"));
+ goto cleanup_iptables;
+ }
+ if (n == 0) {
+ VIR_INFO("Ctdir probing received no data -- 'old' netfilter");
+ goto cleanup_iptables;
+ }
+ VIR_INFO("Ctdir probing received data -- 'fixed' netfilter");
+ iptables_ctdir_corrected = true;
+ break;
+ }
+
+cleanup_iptables:
+ virBufferFreeAndReset(&buf);
+
+ NWFILTER_SET_IPTABLES_SHELLVAR(&buf);
+ virBufferAsprintf(&buf, cmdline,
+ 'D', ' ', port,
+ 'D', ' ', port,
+ 'D', ' ', port);
+ ebiptablesExecCLI(&buf, NULL, NULL);
+
+cleanup:
+ virBufferFreeAndReset(&buf);
+ VIR_FORCE_CLOSE(ssockfd);
+ VIR_FORCE_CLOSE(csockfd);
+}
+
static int
ebiptablesDriverInit(bool privileged)
{
@@ -4341,6 +4461,9 @@ ebiptablesDriverInit(bool privileged)
return -ENOTSUP;
}
+ if (iptables_cmd_path)
+ ebiptablesDriverProbeCtdir();
+
ebiptables_driver.flags = TECHDRV_FLAG_INITIALIZED;
return 0;
11 years, 9 months
[libvirt] [PATCH] Fix parsing of bond interface XML
by Jim Fehlig
Noticed that parsing bond interface XML containing the miimon element
fails
<interface type="bond" name="bond0">
...
<bond mode="active-backup">
<miimon freq="100" carrier="netif"/>
...
</bond>
</interface>
This configuration does not contain the optional updelay and downdelay
attributes, but parsing will fail due to returning the result of
virXPathULong (a -1 when the attribute doesn't exist) from
virInterfaceDefParseBond after examining the updelay attribute.
I considered just adding a ret = 0; near the bottom of
virInterfaceDefParseBond, but see there is no cleanup in the error
label. Instead, just return failure where failure occurs and
return success if the end of the function is reached.
---
src/conf/interface_conf.c | 56 +++++++++++++++++++++--------------------------
1 file changed, 25 insertions(+), 31 deletions(-)
diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c
index 9301ec0..3d45d5c 100644
--- a/src/conf/interface_conf.c
+++ b/src/conf/interface_conf.c
@@ -572,61 +572,58 @@ error:
static int
virInterfaceDefParseBond(virInterfaceDefPtr def,
xmlXPathContextPtr ctxt) {
- int ret = -1;
+ int res;
unsigned long tmp;
def->data.bond.mode = virInterfaceDefParseBondMode(ctxt);
if (def->data.bond.mode < 0)
- goto error;
+ return -1;
- ret = virInterfaceDefParseBondItfs(def, ctxt);
- if (ret != 0)
- goto error;
+ if (virInterfaceDefParseBondItfs(def, ctxt) != 0)
+ return -1;
if (virXPathNode("./miimon[1]", ctxt) != NULL) {
def->data.bond.monit = VIR_INTERFACE_BOND_MONIT_MII;
- ret = virXPathULong("string(./miimon/@freq)", ctxt, &tmp);
- if ((ret == -2) || (ret == -1)) {
+ res = virXPathULong("string(./miimon/@freq)", ctxt, &tmp);
+ if ((res == -2) || (res == -1)) {
virReportError(VIR_ERR_XML_ERROR,
"%s", _("bond interface miimon freq missing or invalid"));
- goto error;
+ return -1;
}
def->data.bond.frequency = (int) tmp;
- ret = virXPathULong("string(./miimon/@downdelay)", ctxt, &tmp);
- if (ret == -2) {
+ res = virXPathULong("string(./miimon/@downdelay)", ctxt, &tmp);
+ if (res == -2) {
virReportError(VIR_ERR_XML_ERROR,
"%s", _("bond interface miimon downdelay invalid"));
- goto error;
- } else if (ret == 0) {
+ return -1;
+ } else if (res == 0) {
def->data.bond.downdelay = (int) tmp;
}
- ret = virXPathULong("string(./miimon/@updelay)", ctxt, &tmp);
- if (ret == -2) {
+ res = virXPathULong("string(./miimon/@updelay)", ctxt, &tmp);
+ if (res == -2) {
virReportError(VIR_ERR_XML_ERROR,
"%s", _("bond interface miimon updelay invalid"));
- goto error;
- } else if (ret == 0) {
+ return -1;
+ } else if (res == 0) {
def->data.bond.updelay = (int) tmp;
}
def->data.bond.carrier = virInterfaceDefParseBondMiiCarrier(ctxt);
- if (def->data.bond.carrier < 0) {
- ret = -1;
- goto error;
- }
+ if (def->data.bond.carrier < 0)
+ return -1;
} else if (virXPathNode("./arpmon[1]", ctxt) != NULL) {
def->data.bond.monit = VIR_INTERFACE_BOND_MONIT_ARP;
- ret = virXPathULong("string(./arpmon/@interval)", ctxt, &tmp);
- if ((ret == -2) || (ret == -1)) {
+ res = virXPathULong("string(./arpmon/@interval)", ctxt, &tmp);
+ if ((res == -2) || (res == -1)) {
virReportError(VIR_ERR_XML_ERROR,
"%s", _("bond interface arpmon interval missing or invalid"));
- goto error;
+ return -1;
}
def->data.bond.interval = (int) tmp;
@@ -635,18 +632,15 @@ virInterfaceDefParseBond(virInterfaceDefPtr def,
if (def->data.bond.target == NULL) {
virReportError(VIR_ERR_XML_ERROR,
"%s", _("bond interface arpmon target missing"));
- ret = -1;
- goto error;
+ return -1;
}
def->data.bond.validate = virInterfaceDefParseBondArpValid(ctxt);
- if (def->data.bond.validate < 0) {
- ret = -1;
- goto error;
- }
+ if (def->data.bond.validate < 0)
+ return -1;
}
-error:
- return ret;
+
+ return 0;
}
static int
--
1.8.0.1
11 years, 9 months