[libvirt] [PATCH v3] conf: Generate address for scsi host device automatically
by Osier Yang
With unknown good reasons, the attribute "bus" of scsi device
address is always set to 0, same for attribute "target". (See
virDomainDiskDefAssignAddress).
Though we might need to change the algorithm to honor "bus"
and "target" too, that's a different issue. The address generator
for scsi host device in this patch just follows the unknown
good reasons, only considering the "controller" and "unit".
It walks through all scsi controllers and their units, to see
if the address $controller:0:0:$unit can be used (if not used
by any disk or scsi host device yet), if found one, it sits on
it, otherwise, it creates a new controller (actually the controller
is implicitly created by someone else), and sits on
$new_controller:0:0:0 instead.
---
v2 - v3:
* Improve the for loop a bit with John's suggestion
v1 - v2:
* A new helper virDomainSCSIDriveAddressIsUsed
* Move virDomainDefMaybeAddHostdevSCSIcontroller
* More comments
* Add testing.
* problems fixed with the testing:
1) s/nscsi_controllers + 1/nscsi_controllers/,
2) Add the controller implicitly after a scsi hostdev def
parsing, as it can use a new scsi controller index
(nscsi_controllers), which should be added implicitly.
---
src/conf/domain_conf.c | 202 ++++++++++++++++++---
.../qemuxml2argv-hostdev-scsi-autogen-address.xml | 95 ++++++++++
...qemuxml2xmlout-hostdev-scsi-autogen-address.xml | 106 +++++++++++
tests/qemuxml2xmltest.c | 2 +
4 files changed, 375 insertions(+), 30 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-autogen-address.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-hostdev-scsi-autogen-address.xml
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 2b4e160..46d49a2 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -3782,6 +3782,141 @@ cleanup:
return ret;
}
+/* Check if a drive type address $controller:0:0:$unit is already
+ * taken by a disk or not.
+ */
+static bool
+virDomainDriveAddressIsUsedByDisk(virDomainDefPtr def,
+ enum virDomainDiskBus type,
+ unsigned int controller,
+ unsigned int unit)
+{
+ virDomainDiskDefPtr disk;
+ int i;
+
+ for (i = 0; i < def->ndisks; i++) {
+ disk = def->disks[i];
+
+ if (disk->bus != type ||
+ disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE)
+ continue;
+
+ if (disk->info.addr.drive.controller == controller &&
+ disk->info.addr.drive.unit == unit &&
+ disk->info.addr.drive.bus == 0 &&
+ disk->info.addr.drive.target == 0)
+ return true;
+ }
+
+ return false;
+}
+
+/* Check if a drive type address $controller:0:0:$unit is already
+ * taken by a host device or not.
+ */
+static bool
+virDomainDriveAddressIsUsedByHostdev(virDomainDefPtr def,
+ enum virDomainHostdevSubsysType type,
+ unsigned int controller,
+ unsigned int unit)
+{
+ virDomainHostdevDefPtr hostdev;
+ int i;
+
+ for (i = 0; i < def->nhostdevs; i++) {
+ hostdev = def->hostdevs[i];
+
+ if (hostdev->source.subsys.type != type)
+ continue;
+
+ if (hostdev->info->addr.drive.controller == controller &&
+ hostdev->info->addr.drive.unit == unit &&
+ hostdev->info->addr.drive.bus == 0 &&
+ hostdev->info->addr.drive.target == 0)
+ return true;
+ }
+
+ return false;
+}
+
+static bool
+virDomainSCSIDriveAddressIsUsed(virDomainDefPtr def,
+ unsigned int controller,
+ unsigned int unit)
+{
+ /* In current implementation, the maximum unit number of a controller
+ * is either 16 or 7 (narrow SCSI bus), and if the maximum unit number
+ * is 16, the controller itself is on unit 7 */
+ if (unit == 7)
+ return true;
+
+ if (virDomainDriveAddressIsUsedByDisk(def, VIR_DOMAIN_DISK_BUS_SCSI,
+ controller, unit) ||
+ virDomainDriveAddressIsUsedByHostdev(def, VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI,
+ controller, unit))
+ return true;
+
+ return false;
+}
+
+/* Find out the next usable "unit" of a specific controller */
+static int
+virDomainControllerSCSINextUnit(virDomainDefPtr def,
+ unsigned int max_unit,
+ unsigned int controller)
+{
+ int i;
+
+ for (i = 0; i < max_unit; i++) {
+ if (!virDomainSCSIDriveAddressIsUsed(def, controller, i))
+ return i;
+ }
+
+ return -1;
+}
+
+#define SCSI_WIDE_BUS_MAX_CONT_UNIT 16
+#define SCSI_NARROW_BUS_MAX_CONT_UNIT 7
+
+static int
+virDomainHostdevAssignAddress(virDomainXMLOptionPtr xmlopt,
+ virDomainDefPtr def,
+ virDomainHostdevDefPtr hostdev)
+{
+ int next_unit;
+ unsigned nscsi_controllers = 0;
+ bool found = false;
+ int i;
+
+ if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI)
+ return -1;
+
+ for (i = 0; i < def->ncontrollers && !found; i++) {
+ if (def->controllers[i]->type != VIR_DOMAIN_CONTROLLER_TYPE_SCSI)
+ continue;
+
+ nscsi_controllers++;
+ next_unit = virDomainControllerSCSINextUnit(def,
+ xmlopt->config.hasWideScsiBus ?
+ SCSI_WIDE_BUS_MAX_CONT_UNIT :
+ SCSI_NARROW_BUS_MAX_CONT_UNIT,
+ def->controllers[i]->idx);
+ if (next_unit >= 0)
+ found = true;
+ }
+
+ hostdev->info->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE;
+
+ hostdev->info->addr.drive.controller = found ?
+ def->controllers[i - 1]->idx :
+ nscsi_controllers;
+ hostdev->info->addr.drive.bus = 0;
+ hostdev->info->addr.drive.target = 0;
+ hostdev->info->addr.drive.unit = found ? next_unit : 0;
+
+ return 0;
+}
+
static int
virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
xmlXPathContextPtr ctxt,
@@ -8802,7 +8937,9 @@ error:
}
static virDomainHostdevDefPtr
-virDomainHostdevDefParseXML(const xmlNodePtr node,
+virDomainHostdevDefParseXML(virDomainXMLOptionPtr xmlopt,
+ virDomainDefPtr vmdef,
+ const xmlNodePtr node,
xmlXPathContextPtr ctxt,
virHashTablePtr bootHash,
unsigned int flags)
@@ -8862,7 +8999,9 @@ virDomainHostdevDefParseXML(const xmlNodePtr node,
}
break;
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI:
- if (def->info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
+ if (def->info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
+ virDomainHostdevAssignAddress(xmlopt, vmdef, def) < 0) {
+
virReportError(VIR_ERR_XML_ERROR, "%s",
_("SCSI host devices must have address specified"));
goto error;
@@ -9271,8 +9410,8 @@ virDomainDeviceDefParse(const char *xmlStr,
goto error;
} else if (xmlStrEqual(node->name, BAD_CAST "hostdev")) {
dev->type = VIR_DOMAIN_DEVICE_HOSTDEV;
- if (!(dev->data.hostdev = virDomainHostdevDefParseXML(node, ctxt, NULL,
- flags)))
+ if (!(dev->data.hostdev = virDomainHostdevDefParseXML(xmlopt, def, node,
+ ctxt, NULL, flags)))
goto error;
} else if (xmlStrEqual(node->name, BAD_CAST "controller")) {
dev->type = VIR_DOMAIN_DEVICE_CONTROLLER;
@@ -10255,6 +10394,30 @@ error:
return NULL;
}
+static int
+virDomainDefMaybeAddHostdevSCSIcontroller(virDomainDefPtr def)
+{
+ /* Look for any hostdev scsi dev */
+ int i;
+ int maxController = -1;
+ virDomainHostdevDefPtr hostdev;
+
+ for (i = 0; i < def->nhostdevs; i++) {
+ hostdev = def->hostdevs[i];
+ if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
+ hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI &&
+ (int)hostdev->info->addr.drive.controller > maxController) {
+ maxController = hostdev->info->addr.drive.controller;
+ }
+ }
+
+ for (i = 0; i <= maxController; i++) {
+ if (virDomainDefMaybeAddController(def, VIR_DOMAIN_CONTROLLER_TYPE_SCSI, i, -1) < 0)
+ return -1;
+ }
+
+ return 0;
+}
static virDomainDefPtr
virDomainDefParseXML(xmlDocPtr xml,
@@ -11618,7 +11781,8 @@ virDomainDefParseXML(xmlDocPtr xml,
for (i = 0; i < n; i++) {
virDomainHostdevDefPtr hostdev;
- hostdev = virDomainHostdevDefParseXML(nodes[i], ctxt, bootHash, flags);
+ hostdev = virDomainHostdevDefParseXML(xmlopt, def, nodes[i],
+ ctxt, bootHash, flags);
if (!hostdev)
goto error;
@@ -11631,6 +11795,9 @@ virDomainDefParseXML(xmlDocPtr xml,
}
def->hostdevs[def->nhostdevs++] = hostdev;
+
+ if (virDomainDefMaybeAddHostdevSCSIcontroller(def) < 0)
+ goto error;
}
VIR_FREE(nodes);
@@ -13232,31 +13399,6 @@ virDomainDefMaybeAddSmartcardController(virDomainDefPtr def)
return 0;
}
-static int
-virDomainDefMaybeAddHostdevSCSIcontroller(virDomainDefPtr def)
-{
- /* Look for any hostdev scsi dev */
- int i;
- int maxController = -1;
- virDomainHostdevDefPtr hostdev;
-
- for (i = 0; i < def->nhostdevs; i++) {
- hostdev = def->hostdevs[i];
- if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
- hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI &&
- (int)hostdev->info->addr.drive.controller > maxController) {
- maxController = hostdev->info->addr.drive.controller;
- }
- }
-
- for (i = 0; i <= maxController; i++) {
- if (virDomainDefMaybeAddController(def, VIR_DOMAIN_CONTROLLER_TYPE_SCSI, i, -1) < 0)
- return -1;
- }
-
- return 0;
-}
-
/*
* Based on the declared <address/> info for any devices,
* add necessary drive controllers which are not already present
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-autogen-address.xml b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-autogen-address.xml
new file mode 100644
index 0000000..21f112b
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-autogen-address.xml
@@ -0,0 +1,95 @@
+<domain type='qemu'>
+ <name>QEMUGuest2</name>
+ <uuid>c7a5fdbd-edaf-9466-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='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/QEMUGuest2'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <controller type='scsi' index='0' model='virtio-scsi'/>
+ <controller type='usb' index='0'/>
+ <controller type='ide' index='0'/>
+ <controller type='pci' index='0' model='pci-root'/>
+ <hostdev mode='subsystem' type='scsi' managed='yes'>
+ <source>
+ <adapter name='scsi_host0'/>
+ <address bus='0' target='0' unit='0'/>
+ </source>
+ </hostdev>
+ <hostdev mode='subsystem' type='scsi' managed='yes'>
+ <source>
+ <adapter name='scsi_host1'/>
+ <address bus='0' target='0' unit='1'/>
+ </source>
+ </hostdev>
+ <hostdev mode='subsystem' type='scsi' managed='yes'>
+ <source>
+ <adapter name='scsi_host2'/>
+ <address bus='0' target='0' unit='2'/>
+ </source>
+ </hostdev>
+ <hostdev mode='subsystem' type='scsi' managed='yes'>
+ <source>
+ <adapter name='scsi_host3'/>
+ <address bus='0' target='0' unit='3'/>
+ </source>
+ </hostdev>
+ <hostdev mode='subsystem' type='scsi' managed='yes'>
+ <source>
+ <adapter name='scsi_host4'/>
+ <address bus='0' target='0' unit='4'/>
+ </source>
+ </hostdev>
+ <hostdev mode='subsystem' type='scsi' managed='yes'>
+ <source>
+ <adapter name='scsi_host5'/>
+ <address bus='0' target='0' unit='5'/>
+ </source>
+ </hostdev>
+ <hostdev mode='subsystem' type='scsi' managed='yes'>
+ <source>
+ <adapter name='scsi_host6'/>
+ <address bus='0' target='0' unit='6'/>
+ </source>
+ </hostdev>
+ <hostdev mode='subsystem' type='scsi' managed='yes'>
+ <source>
+ <adapter name='scsi_host7'/>
+ <address bus='0' target='0' unit='7'/>
+ </source>
+ </hostdev>
+ <hostdev mode='subsystem' type='scsi' managed='yes'>
+ <source>
+ <adapter name='scsi_host8'/>
+ <address bus='0' target='0' unit='8'/>
+ </source>
+ </hostdev>
+ <hostdev mode='subsystem' type='scsi' managed='yes'>
+ <source>
+ <adapter name='scsi_host9'/>
+ <address bus='0' target='0' unit='9'/>
+ </source>
+ <address type='drive' controller='1' bus='0' target='0' unit='5'/>
+ </hostdev>
+ <hostdev mode='subsystem' type='scsi' managed='yes'>
+ <source>
+ <adapter name='scsi_host10'/>
+ <address bus='0' target='0' unit='10'/>
+ </source>
+ </hostdev>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-hostdev-scsi-autogen-address.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-hostdev-scsi-autogen-address.xml
new file mode 100644
index 0000000..e416654
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-hostdev-scsi-autogen-address.xml
@@ -0,0 +1,106 @@
+<domain type='qemu'>
+ <name>QEMUGuest2</name>
+ <uuid>c7a5fdbd-edaf-9466-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='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/QEMUGuest2'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <controller type='scsi' index='0' model='virtio-scsi'/>
+ <controller type='usb' index='0'/>
+ <controller type='ide' index='0'/>
+ <controller type='pci' index='0' model='pci-root'/>
+ <controller type='scsi' index='1'/>
+ <hostdev mode='subsystem' type='scsi' managed='yes'>
+ <source>
+ <adapter name='scsi_host0'/>
+ <address bus='0' target='0' unit='0'/>
+ </source>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </hostdev>
+ <hostdev mode='subsystem' type='scsi' managed='yes'>
+ <source>
+ <adapter name='scsi_host1'/>
+ <address bus='0' target='0' unit='1'/>
+ </source>
+ <address type='drive' controller='0' bus='0' target='0' unit='1'/>
+ </hostdev>
+ <hostdev mode='subsystem' type='scsi' managed='yes'>
+ <source>
+ <adapter name='scsi_host2'/>
+ <address bus='0' target='0' unit='2'/>
+ </source>
+ <address type='drive' controller='0' bus='0' target='0' unit='2'/>
+ </hostdev>
+ <hostdev mode='subsystem' type='scsi' managed='yes'>
+ <source>
+ <adapter name='scsi_host3'/>
+ <address bus='0' target='0' unit='3'/>
+ </source>
+ <address type='drive' controller='0' bus='0' target='0' unit='3'/>
+ </hostdev>
+ <hostdev mode='subsystem' type='scsi' managed='yes'>
+ <source>
+ <adapter name='scsi_host4'/>
+ <address bus='0' target='0' unit='4'/>
+ </source>
+ <address type='drive' controller='0' bus='0' target='0' unit='4'/>
+ </hostdev>
+ <hostdev mode='subsystem' type='scsi' managed='yes'>
+ <source>
+ <adapter name='scsi_host5'/>
+ <address bus='0' target='0' unit='5'/>
+ </source>
+ <address type='drive' controller='0' bus='0' target='0' unit='5'/>
+ </hostdev>
+ <hostdev mode='subsystem' type='scsi' managed='yes'>
+ <source>
+ <adapter name='scsi_host6'/>
+ <address bus='0' target='0' unit='6'/>
+ </source>
+ <address type='drive' controller='0' bus='0' target='0' unit='6'/>
+ </hostdev>
+ <hostdev mode='subsystem' type='scsi' managed='yes'>
+ <source>
+ <adapter name='scsi_host7'/>
+ <address bus='0' target='0' unit='7'/>
+ </source>
+ <address type='drive' controller='1' bus='0' target='0' unit='0'/>
+ </hostdev>
+ <hostdev mode='subsystem' type='scsi' managed='yes'>
+ <source>
+ <adapter name='scsi_host8'/>
+ <address bus='0' target='0' unit='8'/>
+ </source>
+ <address type='drive' controller='1' bus='0' target='0' unit='1'/>
+ </hostdev>
+ <hostdev mode='subsystem' type='scsi' managed='yes'>
+ <source>
+ <adapter name='scsi_host9'/>
+ <address bus='0' target='0' unit='9'/>
+ </source>
+ <address type='drive' controller='1' bus='0' target='0' unit='5'/>
+ </hostdev>
+ <hostdev mode='subsystem' type='scsi' managed='yes'>
+ <source>
+ <adapter name='scsi_host10'/>
+ <address bus='0' target='0' unit='10'/>
+ </source>
+ <address type='drive' controller='1' bus='0' target='0' unit='2'/>
+ </hostdev>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 64a271c..06e4206 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -298,6 +298,8 @@ mymain(void)
DO_TEST("hostdev-scsi-shareable");
DO_TEST("hostdev-scsi-sgio");
+ DO_TEST_DIFFERENT("hostdev-scsi-autogen-address");
+
virObjectUnref(driver.caps);
virObjectUnref(driver.xmlopt);
--
1.8.1.4
11 years, 5 months
[libvirt] [PATCH 0/3] virsh: Add --live, --config, --current to attach-* commands too
by Peter Krempa
In commit 69ce3ffa8d431e9810607c6e00b7cfcc481b491d a pattern was established to
upgrade hotplug commands in virsh. The series containing the patch forgot
to upgrade the attach-* commands too.
Peter Krempa (3):
virsh-domain: Add --live, --config, --current logic to cmdAttachDevice
virsh-domain: Add --live, --config, --current logic to cmdAttachDisk
virsh-domain: Add --live, --config, --current logic to
cmdAttachInterface
tools/virsh-domain.c | 153 ++++++++++++++++++++++++++++++++++++---------------
tools/virsh.pod | 63 ++++++++++++++-------
2 files changed, 153 insertions(+), 63 deletions(-)
--
1.8.2.1
11 years, 5 months
[libvirt] [PATCH 00/11] vCPU hotplug mega-series
by Peter Krempa
This patch series consists of multiple parts:
-patch 1,2: Two trivial cleanups
-patch 3: Improve and refactor vCPU data parsing
-patch 4: Add agent monitor helpers for cpu-hotplug stuff
-patch 5,6,7: Implement universal guest vCPU mapping function
-patch 8: Implement new qemu monitor command for cpu hotplug
-patch 9,10,11: Implement agent based cpu state manipulation API/command
Tip: The new "virsh vcpumap guest --active" command may be used that the
agent actually offlined the vCPU in the guest.
Peter Krempa (11):
virsh-domain-monitor: Remove ATTRIBUTE_UNUSED from a argument
qemu: Use bool instead of int in qemuMonitorSetCPU APIs
qemu: Extract more information about vCPUs and threads
qemu_agent: Introduce helpers for agent based CPU hot(un)plug
lib: Add API to map virtual cpus of a guest
virsh-domain-monitor: Implement command to map guest vCPUs
qemu: Implement virDomainGetVCPUMap for the qemu driver
qemu: Implement new QMP command for cpu hotplug
lib: Add API to modify vCPU state from the guest using the guest agent
virsh-domain: Implement command for virDomainSetGuestVcpu
qemu: Implement virDomainSetGuetVcpu in qemu driver
daemon/remote.c | 54 ++++++++
include/libvirt/libvirt.h.in | 25 ++++
python/generator.py | 1 +
python/libvirt-override-api.xml | 7 +
python/libvirt-override.c | 66 ++++++++++
src/driver.h | 14 ++
src/libvirt.c | 129 +++++++++++++++++++
src/libvirt_public.syms | 7 +
src/qemu/qemu_agent.c | 148 +++++++++++++++++++++
src/qemu/qemu_agent.h | 12 ++
src/qemu/qemu_driver.c | 279 +++++++++++++++++++++++++++++++++++++---
src/qemu/qemu_monitor.c | 11 +-
src/qemu/qemu_monitor.h | 13 +-
src/qemu/qemu_monitor_json.c | 86 ++++++++++---
src/qemu/qemu_monitor_json.h | 4 +-
src/qemu/qemu_monitor_text.c | 94 ++++++++------
src/qemu/qemu_monitor_text.h | 4 +-
src/qemu/qemu_process.c | 63 ++++++---
src/remote/remote_driver.c | 48 +++++++
src/remote/remote_protocol.x | 31 ++++-
src/remote_protocol-structs | 20 +++
tools/virsh-domain-monitor.c | 112 +++++++++++++++-
tools/virsh-domain.c | 77 +++++++++++
tools/virsh.pod | 29 +++++
24 files changed, 1224 insertions(+), 110 deletions(-)
--
1.8.2.1
11 years, 5 months
[libvirt] [PATCH] RPC: Support up to 4096 cpus on the host and 256 in the guest
by Peter Krempa
The RPC limits for cpu maps didn't allow to use libvirt on ultra big
boxes. This patch increases size of the limits to support a maximum of
4096 cpus on the host with the built-in maximum of 256 cpus per guest.
The full cpu map of such a system takes 128 kilobytes and the map for
vcpu pinning is 512 bytes long.
---
src/remote/remote_protocol.x | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 1ebbce7..a94e0db 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -82,13 +82,13 @@ const REMOTE_DOMAIN_ID_LIST_MAX = 16384;
const REMOTE_DOMAIN_NAME_LIST_MAX = 16384;
/* Upper limit on cpumap (bytes) passed to virDomainPinVcpu. */
-const REMOTE_CPUMAP_MAX = 256;
+const REMOTE_CPUMAP_MAX = 512;
/* Upper limit on number of info fields returned by virDomainGetVcpus. */
-const REMOTE_VCPUINFO_MAX = 2048;
+const REMOTE_VCPUINFO_MAX = 4096;
/* Upper limit on cpumaps (bytes) passed to virDomainGetVcpus. */
-const REMOTE_CPUMAPS_MAX = 16384;
+const REMOTE_CPUMAPS_MAX = 131072;
/* Upper limit on migrate cookie. */
const REMOTE_MIGRATE_COOKIE_MAX = 16384;
--
1.8.2.1
11 years, 5 months
[libvirt] Ongoing work on lock contention in qemu driver?
by Peter Feiner
Hello Daniel,
I've been working on improving scalability in OpenStack on libvirt+kvm
for the last couple of months. I'm particularly interested in reducing
the time it takes to create VMs when many VMs are requested in
parallel.
One apparent bottleneck during virtual machine creation is libvirt. As
more VMs are created in parallel, some libvirt calls (i.e.,
virConnectGetLibVersion and virDomainCreateWithFlags) take longer
without a commensurate increase in hardware utilization.
Thanks to your patches in libvirt-1.0.3, the situation has improved.
Some libvirt calls OpenStack makes during VM creation (i.e.,
virConnectDefineXML) have no measurable slowdown when many VMs are
created in parallel. In turn, parallel VM creation in OpenStack is
significantly faster with libvirt-1.0.3. On my standard benchmark
(create 20 VMs in parallel, wait until the VM is ACTIVE, which is
essentially after virDomainCreateWithFlags returns), libvirt-1.0.3
reduces the median creation time from 90s to 60s when compared to
libvirt-0.9.8.
I'd like to know if your concurrency work in the qemu driver is
ongoing. If it isn't, I'd like to pick the work up myself and work on
further improvements. Any advice or insight would be appreciated.
Thanks!
Peter Feiner
11 years, 5 months
[libvirt] [PATCH 1/2] Make virNetDevSetupControl() public.
by Roman Bogorodskiy
This method is useful not only in virnetdev.c.
---
src/libvirt_private.syms | 1 +
src/util/virnetdev.c | 15 +++++++++++++--
src/util/virnetdev.h | 12 ++++++++++++
src/util/virnetdevmacvlan.c | 2 +-
src/util/virnetdevvportprofile.c | 2 +-
5 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index cc734da..d65ecc1 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1526,6 +1526,7 @@ virNetDevSetMTUFromDevice;
virNetDevSetName;
virNetDevSetNamespace;
virNetDevSetOnline;
+virNetDevSetupControl;
virNetDevValidateConfig;
diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index cee4001..f658c6d 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -88,11 +88,22 @@ static int virNetDevSetupControlFull(const char *ifname,
}
-static int virNetDevSetupControl(const char *ifname,
- struct ifreq *ifr)
+int
+virNetDevSetupControl(const char *ifname,
+ struct ifreq *ifr)
{
return virNetDevSetupControlFull(ifname, ifr, VIR_NETDEV_FAMILY, SOCK_DGRAM);
}
+#else
+int
+virNetDevSetupControl(const char *ifname ATTRIBUTE_UNUSED,
+ void *ifr ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENOSYS,
+ _("%s is not supported on this platform"),
+ __func__);
+ return -1;
+}
#endif
diff --git a/src/util/virnetdev.h b/src/util/virnetdev.h
index bc0777c..73c267f 100644
--- a/src/util/virnetdev.h
+++ b/src/util/virnetdev.h
@@ -23,11 +23,23 @@
#ifndef __VIR_NETDEV_H__
# define __VIR_NETDEV_H__
+# include <config.h>
+# include <net/if.h>
+
# include "virsocketaddr.h"
# include "virnetlink.h"
# include "virmacaddr.h"
# include "virpci.h"
+#ifdef HAVE_STRUCT_IFREQ
+int virNetDevSetupControl(const char *ifname,
+ struct ifreq *ifr)
+ ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
+#else
+int virNetDevSetupControl(const char *ifname,
+ void *ifr);
+#endif
+
int virNetDevExists(const char *brname)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c
index 5316520..d5d36e4 100644
--- a/src/util/virnetdevmacvlan.c
+++ b/src/util/virnetdevmacvlan.c
@@ -48,7 +48,7 @@ VIR_ENUM_IMPL(virNetDevMacVLanMode, VIR_NETDEV_MACVLAN_MODE_LAST,
# include <sys/socket.h>
# include <sys/ioctl.h>
-# include <linux/if.h>
+# include <net/if.h>
# include <linux/if_tun.h>
/* Older kernels lacked this enum value. */
diff --git a/src/util/virnetdevvportprofile.c b/src/util/virnetdevvportprofile.c
index 883aa46..71aae24 100644
--- a/src/util/virnetdevvportprofile.c
+++ b/src/util/virnetdevvportprofile.c
@@ -49,7 +49,7 @@ VIR_ENUM_IMPL(virNetDevVPortProfileOp, VIR_NETDEV_VPORT_PROFILE_OP_LAST,
# include <sys/socket.h>
# include <sys/ioctl.h>
-# include <linux/if.h>
+# include <net/if.h>
# include <linux/if_tun.h>
# include "virnetlink.h"
--
1.7.11.5
11 years, 5 months
[libvirt] kFreeBSD pdwtags make check failure
by Guido Günther
Hi,
make check on kFreeBSD currently fails with:
make[3]: Entering directory `/data/home/jenkins/jobs/libvirt-build-debian-jessie-kfreebsd64/workspace/libvirt/src'
GEN remote_protocol-struct
--- remote_protocol-structs 2013-05-03 17:48:29.000000000 +0200
+++ remote_protocol-struct-t3 2013-05-30 22:25:36.716696829 +0200
@@ -67,7 +67,7 @@
struct remote_vcpu_info {
u_int number;
int state;
- uint64_t cpu_time;
+ long unsigned int cpu_time;
int cpu;
};
...
and way more. Full log at:
http://honk.sigxcpu.org:8001/job/libvirt-check-debian-jessie-kfreebsd64/2...
I do wonder what would be the right aproach to fix this up though. The
used types seem compatible at least.
Cheers,
-- Guido
11 years, 5 months
[libvirt] [PATCH] qemu: prevent termination of guests w/hostdev on driver reconnect
by Laine Stump
This should resolve:
https://bugzilla.redhat.com/show_bug.cgi?id=959191
The problem was that qemuUpdateActivePciHostdevs was returning 0
(success) when no hostdevs were present, but would otherwise return -1
(failure) even when it completed successfully. It is only called from
qemuProcessReconnect(), and when qemuProcessReconnect got back an
error, it would not only stop reconnecting, but would terminate the
guest qemu process "to remove danger of it ending up running twice if
user tries to start it again later".
(This bug was introduced in commit 011cf7ad, which was pushed between
v1.0.2 and v1.0.3, so all maintenance branches from v1.0.3 up to 1.0.5
will need this one line patch applied.)
---
src/qemu/qemu_hostdev.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
index 48750c3..5b89bb6 100644
--- a/src/qemu/qemu_hostdev.c
+++ b/src/qemu/qemu_hostdev.c
@@ -176,6 +176,7 @@ int qemuUpdateActivePciHostdevs(virQEMUDriverPtr driver,
}
}
+ ret = 0;
cleanup:
virObjectUnlock(driver->activePciHostdevs);
virObjectUnlock(driver->inactivePciHostdevs);
--
1.7.11.7
11 years, 5 months
[libvirt] [PATCH] vbox: define DYNLIB_NAME for kFreeBSD
by Guido Günther
Similar to what Eric did for Cygwin it helps at least to compile
without --without-vbox
---
src/vbox/vbox_XPCOMCGlue.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/vbox/vbox_XPCOMCGlue.c b/src/vbox/vbox_XPCOMCGlue.c
index 9719014..7809719 100644
--- a/src/vbox/vbox_XPCOMCGlue.c
+++ b/src/vbox/vbox_XPCOMCGlue.c
@@ -50,7 +50,7 @@
/*******************************************************************************
* Defined Constants And Macros *
*******************************************************************************/
-#if defined(__linux__) || defined(__linux_gnu__) || defined(__sun__) || defined(__FreeBSD__) || defined(__OpenBSD__)
+#if defined(__linux__) || defined(__linux_gnu__) || defined(__sun__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__FreeBSD_kernel__)
# define DYNLIB_NAME "VBoxXPCOMC.so"
#elif defined(__APPLE__)
# define DYNLIB_NAME "VBoxXPCOMC.dylib"
--
1.7.10.4
11 years, 5 months
[libvirt] [PATCH] build: skip qemu in tests when !WITH_QEMU
by Eric Blake
A mingw build (where the qemu driver is not built, so WITH_QEMU
is undefined) failed with:
In file included from ../../src/qemu/qemu_command.h:30:0,
from ../../tests/testutilsqemu.h:4,
from ../../tests/networkxml2xmltest.c:14:
../../src/qemu/qemu_conf.h:53:4: error: #error "Port me"
But since testutilsqemu.c is already conditional, the header
should be likewise.
* tests/testutilsqemu.h: Make content conditional.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Pushing under the build-breaker rule. I'm getting closer to a
clean ./autobuild.sh run.
tests/testutilsqemu.h | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h
index 2ca42ab..fc2f5bd 100644
--- a/tests/testutilsqemu.h
+++ b/tests/testutilsqemu.h
@@ -1,8 +1,11 @@
+#include <config.h>
+#ifdef WITH_QEMU
-#include "capabilities.h"
-#include "domain_conf.h"
-#include "qemu/qemu_command.h"
+# include "capabilities.h"
+# include "domain_conf.h"
+# include "qemu/qemu_command.h"
virCapsPtr testQemuCapsInit(void);
virDomainXMLOptionPtr testQemuXMLConfInit(void);
extern qemuBuildCommandLineCallbacks testCallbacks;
+#endif
--
1.8.1.4
11 years, 5 months