[libvirt] [PATCH] nodedev: fix a uninitialized variable build failure
by Chen Hanxiao
Fix a -Werror=maybe-uninitialized warring
Signed-off-by: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
---
src/conf/node_device_conf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index 78bc63f..96524a6 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -1349,7 +1349,7 @@ virNodeDevCapsDefParseXML(xmlXPathContextPtr ctxt,
{
virNodeDevCapsDefPtr caps;
char *tmp;
- int val, ret;
+ int val, ret = -1;
if (VIR_ALLOC(caps) < 0)
return NULL;
--
1.9.0
10 years, 3 months
[libvirt] [PATCH v2 0/3] fix pciexpress memory leak
by Eric Blake
diff in v2: split out trivial fixes, refactor pcie code to
virpci.h, add proper free function to cover all leaks
Eric Blake (3):
nodedev: let compiler help us on switches
nodedev: move pci express types to virpci.h
nodedev: fix pci express memory leak
src/conf/node_device_conf.c | 13 ++++++-------
src/conf/node_device_conf.h | 29 +----------------------------
src/libvirt_private.syms | 1 +
src/node_device/node_device_udev.c | 2 +-
src/util/virpci.c | 15 +++++++++++++++
src/util/virpci.h | 33 ++++++++++++++++++++++++++++++++-
6 files changed, 56 insertions(+), 37 deletions(-)
--
1.9.3
10 years, 3 months
[libvirt] LXC broken on Linux >= 3.15
by Richard Weinberger
Hi!
Kernel commit 23adbe12 ("fs,userns: Change inode_capable to capable_wrt_inode_uidgid")
uncovered a libvirt-lxc issue.
Starting with that commit the kernel correctly checks also the gid of an inode.
Sadly this change breaks libvirt-lxc in a way such that openpty() will always fail
with -EPERM within a container. Therefore ssh and other programs are no longer usable.
Libvirt's virLXCControllerSetupDevPTS() has a hardcoded mount
string for mounting devpts, namely "newinstance,ptmxmode=0666,mode=0620,gid=5",
devpts correctly translates the uid and gid while mounting but libvirt
mounts devpts _before_ setting up the uid/gid mappings.
Therefore the internal gid for the new devpts instance is still 5 instead the mapped gid
and the new check in the kernel will always fail.
We have two options to fix that:
a) virLXCControllerSetupDevPTS() translates the gid (5) by hand and passes the correct
value to devpts. (IMHO hacky)
b) We setup devpts and therefore also the consoles after installing the mappings.
This needs maybe a bit of work.
First I thought a trivial patch like the appended one will do it, but then libvirt
fails to start a guest with no further explanation. Maybe I've later the time to
investigate further.
What do you think?
Thanks,
//richard
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index 2d220eb..3435f42 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -2157,9 +2157,6 @@ virLXCControllerRun(virLXCControllerPtr ctrl)
if (virLXCControllerSetupResourceLimits(ctrl) < 0)
goto cleanup;
- if (virLXCControllerSetupDevPTS(ctrl) < 0)
- goto cleanup;
-
if (virLXCControllerPopulateDevices(ctrl) < 0)
goto cleanup;
@@ -2172,9 +2169,6 @@ virLXCControllerRun(virLXCControllerPtr ctrl)
if (virLXCControllerSetupFuse(ctrl) < 0)
goto cleanup;
- if (virLXCControllerSetupConsoles(ctrl, containerTTYPaths) < 0)
- goto cleanup;
-
if (lxcSetPersonality(ctrl->def) < 0)
goto cleanup;
@@ -2198,6 +2192,12 @@ virLXCControllerRun(virLXCControllerPtr ctrl)
if (virLXCControllerSetupUserns(ctrl) < 0)
goto cleanup;
+ if (virLXCControllerSetupDevPTS(ctrl) < 0)
+ goto cleanup;
+
+ if (virLXCControllerSetupConsoles(ctrl, containerTTYPaths) < 0)
+ goto cleanup;
+
if (virLXCControllerMoveInterfaces(ctrl) < 0)
goto cleanup;
10 years, 3 months
[libvirt] [RFC] require for suggestions on support for ivshmem device
by Wangrui (K)
Hi,
Libvirt does not support ivshmem(Inter-VM Shared Memory) device recently,
thus, I would like to know if there's any plan to support it in the future?
If not, I would like to contribute a serial of patches to do so.
On Jan 28, Wangyufei (James) asked about this question, and Daniel replied with 2 suggestions:
1. Libvirt should be capable of configuring the guest's xml on ivshmem.
2.An ivshmem daemon is needed to run on the host to support it, libvirt is recommended to provide such a daemon.
Please refer to https://www.redhat.com/archives/libvir-list/2014-January/msg01335.html for details.
What I'll do later is the 1st suggestion, the 2nd one is left to be accomplished by someone else.
Here is the detailed work I'll do to support configuration of the guest in libvirt:
virDomainDefParseXML: parse ivshmem device xml when defining dom.xml
virDomainDeviceInfoIterateInternal: iterate ivshmem devices
qemuAssignDevicePCISlots: assign ivshmem device pci slots
virDomainDefFormatInternal: format ivshmem device xml (Eg. virsh edit dom)
virDomainDefFree: free ivshmem device def
qemuBuildCommandLine: build ivshmem device command line when vm starts
qemuAssignDeviceAliases: assign ivshmem device aliases when vm starts
virDomainDeviceDefParse: attach and parse ivshmem device xml
qemuDomainAttachDeviceConfig: attach ivshmem device xml persistently
qemuDomainAttachDeviceLive: attach ivshmem device online
qemuDomainDetachDeviceConfig: detach ivshmem device xml persistently
qemuDomainDetachDeviceLive: detach ivshmem device online
There are two ways to use ivshmem with qemu
(please refer to http://qemu.weilnetz.de/qemu-doc.html#pcsys_005fother_005fdevs ):
1.Guests map a POSIX shared memory region into the guest as a PCI device
that enables zero-copy communication to the application level of the guests, The basic syntax is:
qemu-system-i386-device ivshmem, size = <size in format accepted by -m> [, shm = <shm name>]
2.If desired, interrupts can be sent between guest VMs accessing the same shared memory region.
Interrupt support requires using a shared memory server and using a chardev socket to connect to it.
An example syntax when using the shared memory server is:
qemu-system-i386-device ivshmem, size = <size in format accepted by -m> [, chardev = <id>] [, msi = on]
[, ioeventfd = on] [, vectors = n] [, role = peer | master]
qemu-system-i386-chardev socket, path = <path>, id = <id>
The respective xml configuration for the above 2 qemu command lines are shown as below:
Example1: automatically attach device with KVM
<devices>
<ivshmem role='master'>
<memory name='dom-ivshmem' size='2'/>
</ivshmem>
</devices>
NOTE: "size" means ivshmem size in unit MB, "name" means shm name
"role" is optional, it may be set to "master" or "peer", the default one is "master"
Example2: manually attach device with static PCI slot 4 requested
<devices>
<ivshmem role='master'>
<memory name='dom-ivshmem' size='2'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</ivshmem>
</devices>
Example3: automatically attach device with KVM
<devices>
<ivshmem role='master' type='unix'>
<source mode='connect' path='/tmp/ivshmem'/>
<memory name='dom-ivshmem' size='2'/>
</ivshmem>
</devices>
NOTE: "path" means shared memory socket path which is set by the daemon.
" source mode " and "type" is similar with vmchannel.
I'm looking forward to your suggestions, thank you very much.
10 years, 3 months
[libvirt] [PATCHv2] conf: Add USB sound card support and implement it for qemu
by Peter Krempa
---
Notes:
Version 2:
- added docs
docs/formatdomain.html.in | 5 +++--
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 | 14 ++++++++++++--
tests/qemucapabilitiesdata/caps_1.2.2-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.3.1-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.4.2-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.5.3-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.6.0-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.6.50-1.caps | 1 +
tests/qemuhelptest.c | 9 ++++++---
13 files changed, 33 insertions(+), 8 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 8950959..d1cca19 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -4959,9 +4959,10 @@ qemu-kvm -net nic,model=? /dev/null
The <code>sound</code> element has one mandatory attribute,
<code>model</code>, which specifies what real sound device is emulated.
Valid values are specific to the underlying hypervisor, though typical
- choices are 'es1370', 'sb16', 'ac97', and 'ich6'
+ choices are 'es1370', 'sb16', 'ac97', 'ich6' and 'usb'.
(<span class="since">
- 'ac97' only since 0.6.0, 'ich6' only since 0.8.8</span>)
+ 'ac97' only since 0.6.0, 'ich6' only since 0.8.8,
+ 'usb' only since 1.2.7</span>)
</dd>
</dl>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 910f6e2..814b305 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -458,7 +458,8 @@ VIR_ENUM_IMPL(virDomainSoundModel, VIR_DOMAIN_SOUND_MODEL_LAST,
"pcspk",
"ac97",
"ich6",
- "ich9")
+ "ich9",
+ "usb")
VIR_ENUM_IMPL(virDomainMemballoonModel, VIR_DOMAIN_MEMBALLOON_MODEL_LAST,
"virtio",
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index b988b17..3ddeede 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1166,6 +1166,7 @@ typedef enum {
VIR_DOMAIN_SOUND_MODEL_AC97,
VIR_DOMAIN_SOUND_MODEL_ICH6,
VIR_DOMAIN_SOUND_MODEL_ICH9,
+ VIR_DOMAIN_SOUND_MODEL_USB,
VIR_DOMAIN_SOUND_MODEL_LAST
} virDomainSoundModel;
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 07306e5..eb2bbfd 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -263,6 +263,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
"memory-backend-ram", /* 170 */
"numa",
+ "usb-audio",
);
@@ -1481,6 +1482,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
{ "pvpanic", QEMU_CAPS_DEVICE_PANIC },
{ "usb-kbd", QEMU_CAPS_DEVICE_USB_KBD },
{ "memory-backend-ram", QEMU_CAPS_OBJECT_MEMORY_RAM },
+ { "usb-audio", QEMU_CAPS_OBJECT_USB_AUDIO },
};
static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBlk[] = {
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 4332633..ac65ef3 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -211,6 +211,7 @@ typedef enum {
QEMU_CAPS_CHANGE_BACKING_FILE = 169, /* change name of backing file in metadata */
QEMU_CAPS_OBJECT_MEMORY_RAM = 170, /* -object memory-backend-ram */
QEMU_CAPS_NUMA = 171, /* newer -numa handling with disjoint cpu ranges */
+ QEMU_CAPS_OBJECT_USB_AUDIO = 172, /* usb-audio device support */
QEMU_CAPS_LAST, /* this must always be the last item */
} virQEMUCapsFlags;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index beb8ca8..0ed6a57 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2090,9 +2090,10 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
for (i = 0; i < def->nsounds; i++) {
if (def->sounds[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
continue;
- /* Skip ISA sound card, and PCSPK */
+ /* Skip ISA sound card, PCSPK and usb-audio */
if (def->sounds[i]->model == VIR_DOMAIN_SOUND_MODEL_SB16 ||
- def->sounds[i]->model == VIR_DOMAIN_SOUND_MODEL_PCSPK)
+ def->sounds[i]->model == VIR_DOMAIN_SOUND_MODEL_PCSPK ||
+ def->sounds[i]->model == VIR_DOMAIN_SOUND_MODEL_USB)
continue;
if (virDomainPCIAddressReserveNextSlot(addrs, &def->sounds[i]->info,
@@ -4687,6 +4688,15 @@ qemuBuildSoundDevStr(virDomainDefPtr def,
case VIR_DOMAIN_SOUND_MODEL_ICH6:
model = "intel-hda";
break;
+ case VIR_DOMAIN_SOUND_MODEL_USB:
+ model = "usb-audio";
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_USB_AUDIO)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("usb-audio controller is not supported "
+ "by this QEMU binary"));
+ goto error;
+ }
+ break;
case VIR_DOMAIN_SOUND_MODEL_ICH9:
model = "ich9-intel-hda";
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_ICH9_INTEL_HDA)) {
diff --git a/tests/qemucapabilitiesdata/caps_1.2.2-1.caps b/tests/qemucapabilitiesdata/caps_1.2.2-1.caps
index ebbfb82..c8a379a 100644
--- a/tests/qemucapabilitiesdata/caps_1.2.2-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.2.2-1.caps
@@ -115,4 +115,5 @@
<flag name='enable-fips'/>
<flag name='usb-kbd'/>
<flag name='host-pci-multidomain'/>
+ <flag name='usb-audio'/>
</qemuCaps>
diff --git a/tests/qemucapabilitiesdata/caps_1.3.1-1.caps b/tests/qemucapabilitiesdata/caps_1.3.1-1.caps
index ab631a2..4b7651e 100644
--- a/tests/qemucapabilitiesdata/caps_1.3.1-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.3.1-1.caps
@@ -128,4 +128,5 @@
<flag name='kvm-pit-lost-tick-policy'/>
<flag name='usb-kbd'/>
<flag name='host-pci-multidomain'/>
+ <flag name='usb-audio'/>
</qemuCaps>
diff --git a/tests/qemucapabilitiesdata/caps_1.4.2-1.caps b/tests/qemucapabilitiesdata/caps_1.4.2-1.caps
index e710b60..d146bf9 100644
--- a/tests/qemucapabilitiesdata/caps_1.4.2-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.4.2-1.caps
@@ -129,4 +129,5 @@
<flag name='kvm-pit-lost-tick-policy'/>
<flag name='usb-kbd'/>
<flag name='host-pci-multidomain'/>
+ <flag name='usb-audio'/>
</qemuCaps>
diff --git a/tests/qemucapabilitiesdata/caps_1.5.3-1.caps b/tests/qemucapabilitiesdata/caps_1.5.3-1.caps
index 36758c8..5fa30aa 100644
--- a/tests/qemucapabilitiesdata/caps_1.5.3-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.5.3-1.caps
@@ -137,4 +137,5 @@
<flag name='spiceport'/>
<flag name='usb-kbd'/>
<flag name='host-pci-multidomain'/>
+ <flag name='usb-audio'/>
</qemuCaps>
diff --git a/tests/qemucapabilitiesdata/caps_1.6.0-1.caps b/tests/qemucapabilitiesdata/caps_1.6.0-1.caps
index ca2c236..f364bbf 100644
--- a/tests/qemucapabilitiesdata/caps_1.6.0-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.6.0-1.caps
@@ -144,4 +144,5 @@
<flag name='usb-kbd'/>
<flag name='host-pci-multidomain'/>
<flag name='msg-timestamp'/>
+ <flag name='usb-audio'/>
</qemuCaps>
diff --git a/tests/qemucapabilitiesdata/caps_1.6.50-1.caps b/tests/qemucapabilitiesdata/caps_1.6.50-1.caps
index 4b9f693..10ce1b5 100644
--- a/tests/qemucapabilitiesdata/caps_1.6.50-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.6.50-1.caps
@@ -143,4 +143,5 @@
<flag name='host-pci-multidomain'/>
<flag name='msg-timestamp'/>
<flag name='numa'/>
+ <flag name='usb-audio'/>
</qemuCaps>
diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c
index 105a563..366e36d 100644
--- a/tests/qemuhelptest.c
+++ b/tests/qemuhelptest.c
@@ -842,7 +842,8 @@ mymain(void)
QEMU_CAPS_DEVICE_SCSI_GENERIC_BOOTINDEX,
QEMU_CAPS_VNC_SHARE_POLICY,
QEMU_CAPS_DEVICE_USB_KBD,
- QEMU_CAPS_DEVICE_USB_STORAGE);
+ QEMU_CAPS_DEVICE_USB_STORAGE,
+ QEMU_CAPS_OBJECT_USB_AUDIO);
DO_TEST("qemu-1.2.0", 1002000, 0, 0,
QEMU_CAPS_VNC_COLON,
QEMU_CAPS_NO_REBOOT,
@@ -951,7 +952,8 @@ mymain(void)
QEMU_CAPS_VNC_SHARE_POLICY,
QEMU_CAPS_DEVICE_USB_STORAGE,
QEMU_CAPS_DEVICE_USB_KBD,
- QEMU_CAPS_USB_STORAGE_REMOVABLE);
+ QEMU_CAPS_USB_STORAGE_REMOVABLE,
+ QEMU_CAPS_OBJECT_USB_AUDIO);
DO_TEST("qemu-kvm-1.2.0", 1002000, 1, 0,
QEMU_CAPS_VNC_COLON,
QEMU_CAPS_NO_REBOOT,
@@ -1065,7 +1067,8 @@ mymain(void)
QEMU_CAPS_VNC_SHARE_POLICY,
QEMU_CAPS_DEVICE_USB_STORAGE,
QEMU_CAPS_DEVICE_USB_KBD,
- QEMU_CAPS_USB_STORAGE_REMOVABLE);
+ QEMU_CAPS_USB_STORAGE_REMOVABLE,
+ QEMU_CAPS_OBJECT_USB_AUDIO);
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
--
2.0.0
10 years, 3 months
[libvirt] [PATCH] support vhost-scsi controller
by Zhang Min
libvirt support vhost-scsi controller. The way to config
the vhost-scsi controller is edit the xml file, Format is
as follows:
<controller type='scsi' index='0' model='vhost-scsi'>
<source wwpn='naa.6001405f5e3acbba' event_idx='on'/>
</controller>
the tag of "wwpn" is necessary, the 'model' must be 'vhost-scsi'
'event_idx' is optional.
Signed-off-by: Zhang Min <rudy.zhangmin(a)huawei.com>
---
src/conf/domain_conf.c | 64 +++++++++++++++++++++++++++++++++++++++--
src/conf/domain_conf.h | 10 ++++++
src/qemu/qemu_capabilities.c | 2 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 21 ++++++++++++-
src/vmx/vmx.c | 3 +-
6 files changed, 94 insertions(+), 7 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 54925ba..e42ede7 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -306,7 +306,8 @@ VIR_ENUM_IMPL(virDomainControllerModelSCSI, VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAS
"vmpvscsi",
"ibmvscsi",
"virtio-scsi",
- "lsisas1078");
+ "lsisas1078",
+ "vhost-scsi");
VIR_ENUM_IMPL(virDomainControllerModelUSB, VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST,
"piix3-uhci",
@@ -1290,6 +1291,10 @@ void virDomainControllerDefFree(virDomainControllerDefPtr def)
if (!def)
return;
+ if (def->vhostscsi.wwpn)
+ VIR_FREE(def->vhostscsi.wwpn);
+ memset(&def->vhostscsi, 0, sizeof(def->vhostscsi));
+
virDomainDeviceInfoClear(&def->info);
VIR_FREE(def);
@@ -6051,6 +6056,9 @@ virDomainControllerDefParseXML(xmlNodePtr node,
char *max_sectors = NULL;
xmlNodePtr saved = ctxt->node;
int rc;
+ char *wwpn = NULL;
+ char *event_idx = NULL;
+ int event_idx_num = 0;
ctxt->node = node;
@@ -6087,13 +6095,42 @@ virDomainControllerDefParseXML(xmlNodePtr node,
def->model = -1;
}
+ def->vhostscsi.wwpn = NULL;
cur = node->children;
while (cur != NULL) {
if (cur->type == XML_ELEMENT_NODE) {
if (xmlStrEqual(cur->name, BAD_CAST "driver"))
queues = virXMLPropString(cur, "queues");
- cmd_per_lun = virXMLPropString(cur, "cmd_per_lun");
- max_sectors = virXMLPropString(cur, "max_sectors");
+ else if(xmlStrEqual(cur->name, BAD_CAST "source")) {
+ switch (def->model) {
+ case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VHOST_SCSI:
+ wwpn = virXMLPropString(cur, "wwpn");
+ if (wwpn && !STREQ(wwpn,"")) {
+ def->vhostscsi.wwpn = wwpn;
+ wwpn = NULL;
+ } else {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("vhost-scsi:wwpn can't be null"));
+ goto error;
+ }
+
+ event_idx = virXMLPropString(cur, "event_idx");
+ if (event_idx) {
+ if ((event_idx_num = virDomainVirtioEventIdxTypeFromString(event_idx)) <= 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown vhost-scsi event_idx mode '%s'"),
+ event_idx);
+ goto error;
+ }
+ def->vhostscsi.event_idx = event_idx_num;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ cmd_per_lun = virXMLPropString(cur, "cmd_per_lun");
+ max_sectors = virXMLPropString(cur, "max_sectors");
}
cur = cur->next;
}
@@ -6216,6 +6253,12 @@ virDomainControllerDefParseXML(xmlNodePtr node,
goto error;
}
+ if (def->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VHOST_SCSI &&
+ def->vhostscsi.wwpn == NULL) {
+ virReportError(VIR_ERR_XML_ERROR,_("vhost-scsi:wwpn can't be null"));
+ goto error;
+ }
+
cleanup:
ctxt->node = saved;
VIR_FREE(type);
@@ -6224,6 +6267,8 @@ virDomainControllerDefParseXML(xmlNodePtr node,
VIR_FREE(queues);
VIR_FREE(cmd_per_lun);
VIR_FREE(max_sectors);
+ VIR_FREE(wwpn);
+ VIR_FREE(event_idx);
return def;
@@ -15300,10 +15345,21 @@ virDomainControllerDefFormat(virBufferPtr buf,
break;
}
- if (def->queues || def->cmd_per_lun || def->max_sectors ||
+ if (def->queues || def->cmd_per_lun || def->max_sectors || def->vhostscsi.wwpn
virDomainDeviceInfoIsSet(&def->info, flags) || pcihole64) {
virBufferAddLit(buf, ">\n");
virBufferAdjustIndent(buf, 2);
+
+ if (def->vhostscsi.wwpn) {
+ virBufferAsprintf(buf, " <source wwpn='%s'", def->vhostscsi.wwpn);
+
+ if (def->vhostscsi.event_idx) {
+ virBufferAsprintf(buf, " event_idx='%s'",
+ virDomainVirtioEventIdxTypeToString(def->vhostscsi.event_idx));
+ }
+ virBufferAddLit(buf, "/>\n");
+ }
+
if (def->queues)
virBufferAsprintf(buf, "<driver queues='%u'/>\n", def->queues);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index a00e30a..7b3cfd8 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -679,6 +679,7 @@ typedef enum {
VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI,
VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI,
VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1078,
+ VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VHOST_SCSI,
VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST
} virDomainControllerModelSCSI;
@@ -713,6 +714,14 @@ struct _virDomainPCIControllerOpts {
unsigned long pcihole64size;
};
+/* Stores the vhost-scsi controller configuration */
+typedef struct _virDomainControllerVhostDef virDomainControllerVhostDef;
+typedef virDomainControllerVhostDef *virDomainControllerVhostDefPtr;
+struct _virDomainControllerVhostDef {
+ char *wwpn;
+ int event_idx;
+};
+
/* Stores the virtual disk controller configuration */
struct _virDomainControllerDef {
int type;
@@ -721,6 +730,7 @@ struct _virDomainControllerDef {
unsigned int queues;
unsigned int cmd_per_lun;
unsigned int max_sectors;
+ virDomainControllerVhostDef vhostscsi;
union {
virDomainVirtioSerialOpts vioserial;
virDomainPCIControllerOpts pciopts;
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 40ebf29..bf124b7 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -258,6 +258,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
"host-pci-multidomain",
"msg-timestamp",
"active-commit",
+ "vhost-scsi-pci",
);
@@ -1445,6 +1446,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 },
+ { "vhost-scsi-pci", QEMU_CAPS_VHOST_SCSI },
{ "megasas", QEMU_CAPS_SCSI_MEGASAS },
{ "spicevmc", QEMU_CAPS_DEVICE_SPICEVMC },
{ "qxl-vga", QEMU_CAPS_DEVICE_QXL_VGA },
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 0ea8de8..9eb18f4 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -208,6 +208,7 @@ typedef enum {
QEMU_CAPS_HOST_PCI_MULTIDOMAIN = 166, /* support domain > 0 in host pci address */
QEMU_CAPS_MSG_TIMESTAMP = 167, /* -msg timestamp */
QEMU_CAPS_ACTIVE_COMMIT = 168, /* block-commit works without 'top' */
+ QEMU_CAPS_VHOST_SCSI = 153, /* -device vhost-scsi-pci */
QEMU_CAPS_LAST, /* this must always be the last item */
} virQEMUCapsFlags;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index fb64cda..02edad2 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -701,6 +701,14 @@ qemuSetSCSIControllerModel(virDomainDefPtr def,
return -1;
}
break;
+ case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VHOST_SCSI:
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VHOST_SCSI)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("This QEMU doesn't support "
+ "vhost scsi controller"));
+ return -1;
+ }
+ break;
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI:
/*TODO: need checking work here if necessary */
break;
@@ -4119,8 +4127,9 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef,
virBuffer buf = VIR_BUFFER_INITIALIZER;
int model;
- if (!(def->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI &&
- def->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI)) {
+ if (!((def->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI) &&
+ (def->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI ||
+ def->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VHOST_SCSI))) {
if (def->queues) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("'queues' is only supported by virtio-scsi controller"));
@@ -4157,6 +4166,14 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef,
else
virBufferAddLit(&buf, "virtio-scsi-pci");
break;
+ case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VHOST_SCSI:
+ virBufferAddLit(&buf, "vhost-scsi-pci");
+ virBufferAsprintf(&buf, ",wwpn=%s", def->vhostscsi.wwpn);
+ if (def->vhostscsi.event_idx) {
+ virBufferAsprintf(&buf, ",event_idx=%s",
+ virDomainVirtioEventIdxTypeToString(def->vhostscsi.event_idx));
+ }
+ break;
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC:
virBufferAddLit(&buf, "lsi");
break;
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index cd6c51e..ace6ccd 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -517,7 +517,8 @@ VIR_ENUM_IMPL(virVMXControllerModelSCSI, VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST,
"pvscsi",
"UNUSED ibmvscsi",
"UNUSED virtio-scsi",
- "UNUSED lsisas1078");
+ "UNUSED lsisas1078",
+ "UNUSED vhost-scsi");
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
--
zhang min
10 years, 3 months
[libvirt] [PATCH 0/2] qemu: add vhost-scsi-pci support
by Nicholas A. Bellinger
From: Nicholas Bellinger <nab(a)linux-iscsi.org>
Hi Daniel & Co,
The following is the patch series to add support for vhost-scsi-pci
from QEMU >= v1.5.x into libvirt. It includes proper support for
passing a pre-opened vhostfd into vhost-scsi, which is required in
order to properly support nova performing a device_add for adding
a individual vhost-scsi-pci WWPN endpoint -> SCSI controller.
The logic closely follows what vhost-net already does in order to
allow a child qemu process to interact with the vhost-scsi character
device for registering vhost memory, setting vhost-scsi endpoints,
etc.
This code has been tested using openstack nova volume-attach, using
a Juno v2 development head from 07192014.
Thank you,
--nab
Mike Perez (1):
qemu: add vhost-scsi-pci definitions
Nicholas Bellinger (1):
qemu: add support vhost-scsi-pci for device_add hotplug
Makefile.am | 2 +-
docs/formatdomain.html.in | 20 ++--
docs/schemas/domaincommon.rng | 5 +
src/conf/domain_conf.c | 20 +++-
src/conf/domain_conf.h | 2 +
src/qemu/qemu_capabilities.c | 2 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 115 ++++++++++++++++++--
src/qemu/qemu_command.h | 8 +-
src/qemu/qemu_hotplug.c | 47 +++++++-
src/qemu/qemu_monitor.c | 24 ++++
src/qemu/qemu_monitor.h | 4 +
src/vmx/vmx.c | 1 +
tests/qemucapabilitiesdata/caps_1.5.3-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.6.0-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.6.50-1.caps | 1 +
.../qemuxml2argv-disk-vhost-scsi-cmd_per_lun.args | 9 ++
.../qemuxml2argv-disk-vhost-scsi-cmd_per_lun.xml | 29 +++++
.../qemuxml2argv-disk-vhost-scsi-max_sectors.args | 9 ++
.../qemuxml2argv-disk-vhost-scsi-max_sectors.xml | 29 +++++
.../qemuxml2argv-disk-vhost-scsi-num_queues.args | 9 ++
.../qemuxml2argv-disk-vhost-scsi-num_queues.xml | 29 +++++
.../qemuxml2argv-disk-vhost-scsi-wwpn.args | 9 ++
.../qemuxml2argv-disk-vhost-scsi-wwpn.xml | 29 +++++
tests/qemuxml2argvtest.c | 12 ++
tests/qemuxml2xmltest.c | 4 +
26 files changed, 399 insertions(+), 23 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-vhost-scsi-cmd_per_lun.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-vhost-scsi-cmd_per_lun.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-vhost-scsi-max_sectors.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-vhost-scsi-max_sectors.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-vhost-scsi-num_queues.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-vhost-scsi-num_queues.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-vhost-scsi-wwpn.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-vhost-scsi-wwpn.xml
--
1.7.9.5
10 years, 3 months
[libvirt] [PATCH] qemu: sound: Fix uninitialized model string
by Peter Krempa
Commit e5f36698e3efc3d258b2996c7423c47e05ec52b2 introduces a
false-positive build failure in the sound card model handling switch.
Initialize the model to NULL although the value should never be used.
---
Notes:
Pushed under the build-breaker and trivial rules.
src/qemu/qemu_command.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index cb3c584..beb8ca8 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4674,7 +4674,7 @@ qemuBuildSoundDevStr(virDomainDefPtr def,
virQEMUCapsPtr qemuCaps)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
- const char *model;
+ const char *model = NULL;
/* Hack for devices with different names in QEMU and libvirt */
switch ((virDomainSoundModel) sound->model) {
--
2.0.0
10 years, 3 months
[libvirt] [PATCH 0/2] add support for --config in setmaxmem command
by Chen Hanxiao
Chen Hanxiao (2):
LXC: add support for --config in setmaxmem command
LXC: use lxcDomainSetMemoryFlags to do lxcDomainSetMaxMemory's work
src/lxc/lxc_driver.c | 105 +++++++++++++++++++++++++--------------------------
1 file changed, 51 insertions(+), 54 deletions(-)
--
1.9.0
10 years, 3 months
[libvirt] [PATCH 0/2] qemu: usb-audio support and cleanup of sound card handling
by Peter Krempa
qemu supports the usb sound card for a while, add support to libvirt too
Peter Krempa (2):
conf: Add USB sound card support and implement it for qemu
qemu: sound: Handle all possible sound cards in switch statement
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 | 33 +++++++++++++++++++--------
tests/qemucapabilitiesdata/caps_1.2.2-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.3.1-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.4.2-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.5.3-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.6.0-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.6.50-1.caps | 1 +
tests/qemuhelptest.c | 9 +++++---
12 files changed, 41 insertions(+), 14 deletions(-)
--
2.0.0
10 years, 3 months