[libvirt] [PATCH 0/8 v2] Glue domain and storage
by Osier Yang
This is the 4th part to implement NPIV migration support [1].
Part 1 and part 2 are pushed.
Part 3 (v3: pending for review):
https://www.redhat.com/archives/libvir-list/2013-March/msg01440.html
======
This introduces new XMLs to specify the disk source with storage like
<disk type='volume' device='disk'>
<driver name='qemu' type='raw' cache='none'/>
<source pool="$pool_name" volume='$vol_name'/>
<seclabel relabel='no'/>
</source>
<target dev='vdb' bus='virtio'/>
</disk>
And before domain starting, and disk attaching/updating, the source represented
by storage is translated into the real underlying storage volume.
Future work:
* Support network volume
* Support disk backing chain?
v1 - v2:
* Invoke storage APIs to translate the source directly in qemu driver
* 1/8 in v1 is pushed.
* 2/8 in v1 is splitted (the code refactoring now is a standalone patch)
* Support shared disk for volume type disk
* Support sgio setting for volume type disk
* No network volume support in v2
RFC - v1:
* The XMLs are more simpler - only using pool name and volume
name to specify disk source.
* Support network pool (rbd, and sheepdog)
* Support startupPolicy for volume type disk
* Support seclabels for volume type disk
* Fix bugs on disk source formating
Osier Yang (8):
conf: New helper virDomainDiskSourceDefFormat to format the disk
source
Introduce new XMLs to specify disk source using libvirt storage
qemu: Translate the pool disk source when building drive string
Support startupPolicy for 'volume' disk
Support seclabels for volume type disk
qemu: Translate the pool disk source earlier
qemu: Support shareable volume type disk
qemu: Support sgio setting for volume type disk
docs/formatdomain.html.in | 28 ++-
docs/schemas/domaincommon.rng | 24 ++
src/conf/domain_conf.c | 274 ++++++++++++++-------
src/conf/domain_conf.h | 10 +
src/qemu/qemu_command.c | 32 +++
src/qemu/qemu_command.h | 1 -
src/qemu/qemu_conf.c | 68 ++++-
src/qemu/qemu_conf.h | 3 +
src/qemu/qemu_domain.c | 4 +-
src/qemu/qemu_driver.c | 16 +-
src/qemu/qemu_process.c | 14 +-
.../qemuxml2argv-disk-source-pool.xml | 37 +++
tests/qemuxml2xmltest.c | 1 +
13 files changed, 406 insertions(+), 106 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool.xml
--
1.8.1.4
11 years, 7 months
[libvirt] [PATCH 0/7 v3] Persistent vHBA support in storage driver
by Osier Yang
v2: https://www.redhat.com/archives/libvir-list/2013-February/msg00118.html
v2 - v3:
* 6/8 of v1 is ACKed/pushed.
* Use virStringToLong_ui instead of sscanf
* Fixed various nits pointed out by John
This is the 3rd part to implement NPIV migration support [1].
Part 1: (pushed)
https://www.redhat.com/archives/libvir-list/2013-February/msg00112.html
Part 2: (pushed)
https://www.redhat.com/archives/libvir-list/2013-January/msg00859.html
Osier Yang (7):
New XML attributes for storage pool source adapter
storage: Make the adapter name be consistent with node device driver
storage: Move virStorageBackendSCSIGetHostNumber into iscsi backend
phyp: Prohibit fc_host adapter for phyp driver
util: Add helper to get the scsi host name by iterating over sysfs
storage: Add startPool and stopPool for scsi backend
storage: Guess the parent if it's not specified for vHBA
docs/formatstorage.html.in | 17 +-
docs/schemas/storagepool.rng | 33 +++-
src/conf/storage_conf.c | 132 +++++++++++++-
src/conf/storage_conf.h | 23 ++-
src/libvirt_private.syms | 4 +
src/phyp/phyp_driver.c | 15 +-
src/storage/storage_backend_iscsi.c | 39 +++-
src/storage/storage_backend_scsi.c | 202 +++++++++++++++------
src/storage/storage_backend_scsi.h | 3 -
src/util/virutil.c | 202 +++++++++++++++++++++
src/util/virutil.h | 11 +-
.../pool-scsi-type-fc-host.xml | 15 ++
.../pool-scsi-type-scsi-host.xml | 15 ++
.../pool-scsi-type-fc-host.xml | 18 ++
.../pool-scsi-type-scsi-host.xml | 18 ++
tests/storagepoolxml2xmlout/pool-scsi.xml | 2 +-
tests/storagepoolxml2xmltest.c | 2 +
17 files changed, 669 insertions(+), 82 deletions(-)
create mode 100644 tests/storagepoolxml2xmlin/pool-scsi-type-fc-host.xml
create mode 100644 tests/storagepoolxml2xmlin/pool-scsi-type-scsi-host.xml
create mode 100644 tests/storagepoolxml2xmlout/pool-scsi-type-fc-host.xml
create mode 100644 tests/storagepoolxml2xmlout/pool-scsi-type-scsi-host.xml
--
1.8.0.1
11 years, 7 months
[libvirt] [PATCH 1/2] cgroup: export virCgroupRemoveRecursively
by Gao feng
We will use virCgroupRemoveRecursively to remove cgroup
directories in the coming patch.
Signed-off-by: Gao feng <gaofeng(a)cn.fujitsu.com>
---
src/libvirt_private.syms | 1 +
src/util/vircgroup.c | 4 ++--
src/util/vircgroup.h | 1 +
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index dc01bfa..8cc50c4 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1118,6 +1118,7 @@ virCgroupKillRecursive;
virCgroupMounted;
virCgroupMoveTask;
virCgroupPathOfController;
+virCgroupRemoveRecursively;
virCgroupRemove;
virCgroupSetBlkioDeviceWeight;
virCgroupSetBlkioWeight;
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 532e704..6998f13 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -686,7 +686,7 @@ cleanup:
#endif
#if defined _DIRENT_HAVE_D_TYPE
-static int virCgroupRemoveRecursively(char *grppath)
+int virCgroupRemoveRecursively(char *grppath)
{
DIR *grpdir;
struct dirent *ent;
@@ -735,7 +735,7 @@ static int virCgroupRemoveRecursively(char *grppath)
return rc;
}
#else
-static int virCgroupRemoveRecursively(char *grppath ATTRIBUTE_UNUSED)
+int virCgroupRemoveRecursively(char *grppath ATTRIBUTE_UNUSED)
{
/* Claim no support */
return -ENXIO;
diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h
index 2ed6ff9..ea42fa2 100644
--- a/src/util/vircgroup.h
+++ b/src/util/vircgroup.h
@@ -157,6 +157,7 @@ int virCgroupGetCpusetMems(virCgroupPtr group, char **mems);
int virCgroupSetCpusetCpus(virCgroupPtr group, const char *cpus);
int virCgroupGetCpusetCpus(virCgroupPtr group, char **cpus);
+int virCgroupRemoveRecursively(char *grppath);
int virCgroupRemove(virCgroupPtr group);
void virCgroupFree(virCgroupPtr *group);
--
1.7.11.7
11 years, 7 months
[libvirt] [PATCH v3 1/2] Optimize machine option to set more options with it
by Li Zhang
From: Li Zhang <zhlcindy(a)linux.vnet.ibm.com>
Currently, -machine option is used only when dump-guest-core is set.
To use options defined in machine option for newer version of QEMU,
it needs to use -machine xxx, and to be compatible with older version
-M, this patch addes QEMU_CAPS_MACHINE_OPT capability for newer
version which supports -machine option.
Signed-off-by: Li Zhang <zhlcindy(a)linux.vnet.ibm.com>
---
v3 -> v2:
* Set QEMU_CAPS_MACHINE_OPT with help string
* Set QEMU_CAPS_DUMP_GUEST_CORE with QMP
v2 -> v1:
* Split the patch to 2 parts suggested by Daniel P.Berrange
* Rename QEMU_CAPS_MACH_OPT to QEMU_CAPS_MACHINE_OPT
* Remove version 1.1 assertion for QEMU_CAPS_MACHINE_OPT
src/qemu/qemu_capabilities.c | 11 +++++++++++
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 32 ++++++++++++++++++--------------
tests/qemuhelptest.c | 4 ++++
tests/qemuxml2argvtest.c | 6 +++---
5 files changed, 37 insertions(+), 17 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 861d3c4..7d459db 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -213,6 +213,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
"virtio-ccw",
"dtb",
"megasas",
+
+ "machine-opt", /* 135 */
);
struct _virQEMUCaps {
@@ -1091,6 +1093,9 @@ virQEMUCapsComputeCmdFlags(const char *help,
if (strstr(help, "-dtb"))
virQEMUCapsSet(qemuCaps, QEMU_CAPS_DTB);
+ if (strstr(help, "-machine"))
+ virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_OPT);
+
/*
* Handling of -incoming arg with varying features
* -incoming tcp (kvm >= 79, qemu >= 0.10.0)
@@ -2442,6 +2447,12 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps,
virQEMUCapsInitQMPBasic(qemuCaps);
+ /* machine option is supported for newer version */
+ virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_OPT);
+
+ /* -dump-guest-core is supported for newer version*/
+ virQEMUCapsSet(qemuCaps, QEMU_CAPS_DUMP_GUEST_CORE);
+
if (!(archstr = qemuMonitorGetTargetArch(mon)))
goto cleanup;
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 7101f67..2595868 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -174,6 +174,7 @@ enum virQEMUCapsFlags {
QEMU_CAPS_VIRTIO_CCW = 132, /* -device virtio-*-ccw */
QEMU_CAPS_DTB = 133, /* -dtb file */
QEMU_CAPS_SCSI_MEGASAS = 134, /* -device megasas */
+ QEMU_CAPS_MACHINE_OPT = 135, /* -machine xxxx*/
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 a0c278f..0ee634b 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -5197,6 +5197,8 @@ qemuBuildMachineArgStr(virCommandPtr cmd,
const virDomainDefPtr def,
virQEMUCapsPtr qemuCaps)
{
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+
/* This should *never* be NULL, since we always provide
* a machine in the capabilities data for QEMU. So this
* check is just here as a safety in case the unexpected
@@ -5204,27 +5206,29 @@ qemuBuildMachineArgStr(virCommandPtr cmd,
if (!def->os.machine)
return 0;
- if (!def->mem.dump_core) {
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_OPT)) {
/* if no parameter to the machine type is needed, we still use
* '-M' to keep the most of the compatibility with older versions.
*/
virCommandAddArgList(cmd, "-M", def->os.machine, NULL);
} else {
- if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DUMP_GUEST_CORE)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- "%s", _("dump-guest-core is not available "
- " with this QEMU binary"));
- return -1;
- }
- /* However, in case there is a parameter to be added, we need to
- * use the "-machine" parameter because qemu is not parsing the
- * "-M" correctly */
virCommandAddArg(cmd, "-machine");
- virCommandAddArgFormat(cmd,
- "%s,dump-guest-core=%s",
- def->os.machine,
- virDomainMemDumpTypeToString(def->mem.dump_core));
+ virBufferAsprintf(&buf, "%s", def->os.machine);
+
+ if (def->mem.dump_core) {
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DUMP_GUEST_CORE)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ "%s", _("dump-guest-core is not available "
+ " with this QEMU binary"));
+ return -1;
+ }
+
+ virBufferAsprintf(&buf, ",dump-guest-core=%s",
+ virDomainMemDumpTypeToString(def->mem.dump_core));
+ }
+
+ virCommandAddArg(cmd, virBufferContentAndReset(&buf));
}
return 0;
diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c
index a28109a..0c7e607 100644
--- a/tests/qemuhelptest.c
+++ b/tests/qemuhelptest.c
@@ -718,6 +718,7 @@ mymain(void)
QEMU_CAPS_SCSI_LSI,
QEMU_CAPS_BLOCKIO,
QEMU_CAPS_VNC,
+ QEMU_CAPS_MACHINE_OPT,
QEMU_CAPS_DEVICE_QXL,
QEMU_CAPS_DEVICE_VGA,
QEMU_CAPS_DEVICE_CIRRUS_VGA,
@@ -806,6 +807,7 @@ mymain(void)
QEMU_CAPS_VIRTIO_SCSI,
QEMU_CAPS_BLOCKIO,
QEMU_CAPS_VNC,
+ QEMU_CAPS_MACHINE_OPT,
QEMU_CAPS_DEVICE_QXL,
QEMU_CAPS_DEVICE_VGA,
QEMU_CAPS_DEVICE_CIRRUS_VGA,
@@ -903,6 +905,7 @@ mymain(void)
QEMU_CAPS_SECCOMP_SANDBOX,
QEMU_CAPS_DUMP_GUEST_CORE,
QEMU_CAPS_VNC,
+ QEMU_CAPS_MACHINE_OPT,
QEMU_CAPS_USB_REDIR_BOOTINDEX,
QEMU_CAPS_USB_HOST_BOOTINDEX,
QEMU_CAPS_DEVICE_QXL,
@@ -1009,6 +1012,7 @@ mymain(void)
QEMU_CAPS_SECCOMP_SANDBOX,
QEMU_CAPS_DUMP_GUEST_CORE,
QEMU_CAPS_VNC,
+ QEMU_CAPS_MACHINE_OPT,
QEMU_CAPS_USB_REDIR_BOOTINDEX,
QEMU_CAPS_USB_HOST_BOOTINDEX,
QEMU_CAPS_DEVICE_QXL,
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 38787ac..4b45c55 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -363,9 +363,9 @@ mymain(void)
DO_TEST("minimal-s390", QEMU_CAPS_NAME);
DO_TEST("machine-aliases1", NONE);
DO_TEST("machine-aliases2", QEMU_CAPS_KVM);
- DO_TEST("machine-core-on", QEMU_CAPS_DUMP_GUEST_CORE);
- DO_TEST("machine-core-off", QEMU_CAPS_DUMP_GUEST_CORE);
- DO_TEST_FAILURE("machine-core-on", NONE);
+ DO_TEST("machine-core-on", QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_DUMP_GUEST_CORE);
+ DO_TEST("machine-core-off", QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_DUMP_GUEST_CORE);
+ DO_TEST_FAILURE("machine-core-on", QEMU_CAPS_MACHINE_OPT, NONE);
DO_TEST("boot-cdrom", NONE);
DO_TEST("boot-network", NONE);
DO_TEST("boot-floppy", NONE);
--
1.7.10.1
11 years, 7 months
[libvirt] RFC: dhcp <option> element revisited
by Laine Stump
Before 1.0.3, Pieter Hollants kindly implemented the XML I had earlier
suggested to support configure-by-number dhcp options in libvirt networks.
https://www.redhat.com/archives/libvir-list/2013-February/msg01251.html
I also posted a followup patch for a "force" attribute to options:
https://www.redhat.com/archives/libvir-list/2013-February/msg01349.html
I actually pushed a slightly fixed version of Pieter's patch, and was
looking for an ACK to mine when Eric questioned whether it was all
really ready to push since we hadn't implemented *named* options
(although there is no official RFC standard for the names of options,
dnsmasq uses a pretty good set of lowercase-dash-separated names that
make sense, and would certainly make it easier to decode the config). At
the time I had just started trying to write such a patch, and was
realizing that the XML we'd come up with didn't have any provision to
easily deal with an option that took a list of values (multiple IP
addresses, multiple domain names, etc); for numbered options we could
just punt on this and say "put the multiple values in the single 'value'
attribute, separated by commas", but we all know that's a cop-out, so I
decided to temporarily pull Pieter's patch to avoid regrets over getting
something suboptimal in an official release.
That's all the history. Now on to discussing how we should modify these
patches to be exactly what we want.
I tried digging down into the data of the options to try and make an
exhaustive XML representation, with the results below (these would all
go directly inside the <dhcp> element of a libvirt network). But it's
starting to seem like the deeper I go, the deeper it gets (the
classless-static-route option is the current "deepest", and I haven't
even attempted to do anything about vendor-specific options), so I'm
starting to wonder where to draw the line - see the "STEPPING BACK"
section at the bottom.
1) numeric option, single value:
<option code='119'>
<value type='domain' data='a.example.com'/>
</option>
(Note that I changed "number" to "code" after seeing that suggestion in
[1] because that's what it's called in the RFC).
(Also note that the actual encoding of option 119's data is more
complicated than described here [2], but it's complicated enough that I
think whatever dhcp server implementation is underneath libvirt will
need to know the details anyway and decided what we should go for with
the "type" attribute is enough for libvirt to validate the input, not
necessarily to encode it into a DHCP response packet; any translation
from the validated input will be handled internally to the backend
driver (currently bridge_driver.c which uses dnsmasq) (I'm actually
wondering if type is needed in the XML at all, since the type of any
piece of data is always either implicit, or unknown (in which case we
just accept any text and pass it through to the backend driver).)
2) numeric option, multiple values:
<option code='119' force='yes'>
<value type='domain' data='a.example.com'/>
<value type='domain' data='b.example.com'/>
<value type='domain' data='c.example.com'/>
</option>
3) named option, single simple value:
<option name='ip-forward-enable'>
<value type='boolean' data='yes'/>
</option>
4) named option, multiple simple values:
<option name='dns-server'>
<value type='ipv4Addr' data='10.1.1.1'/>
<value type='ipv4Addr' data='10.1.1.2'/>
</option>
<option
(for all named options and known numeric options, the "type" field would
be optional, as libvirt will already have an internal table associating
option names/code with the type of data, as well as whether or not
multiples are allowed)
5) named option, multiple compound values:
<option name='classless-static-route'>
<value type='compound'>
<value type='ipv4Addr' data='1.2.3.0'/>
<value type='ipv4Prefix' data='24'/>
<value type='ipv4Addr' data='192.168.122.5'/>
</value>
<value type='compound'>
<value type='ipv4Addr' data='1.2.4.0'/>
<value type='ipv4Prefix' data='24'/>
<value type='ipv4Addr' data='192,.168.122.6'/>
</value>
</option>
(I suppose this could also be done as a flat list, since every static
route needs all three)
The types I can see that we need (to describe everything in RFC2132
(except vendor-specific options) and the other options I know about) are:
ipv4Addr
ipv4Prefix
text
path
domain
boolean
number
ANOTHER POSSIBILITY
===================
Another way of dealing with options that permit lists of multiple values
- just specify the option multiple times, e.g.:
<option name='dnsServer' type='ipv4Addr' data='10.1.1.1'/>
<option name='dnsServer' type='ipv4Addr' data='10.1.1.2'/>
============================
BTW - another point; I had earlier said that we didn't need to worry
about an option number blacklist/whitelist. After looking through the
options in RFC 2132, I've changed my mind - many of the option codes
(particularly those in the 50's) aren't really general purpose options,
but are used by dhcp as integral parts of implementing the exchange
sequence between the server and client. So I think what we need to do is
have a whitelist that has an entry for every dhcp option we are willing
to accept. It would contain:
uint8 code;
const char *name; /* could be "", in which case we don't recognize a
name for it */
unsigned int flags; /* whether or not multiple values are allowed,
name recognized by dnsmasq */
/* some representation of type here - what to do about the "compound"
type? */
STEPPING BACK
-------------
So are we going too far with this? Or should we dial it back to the
original proposal in Pieter's patch and just say that
1) if <option> is used, the data is passed through unqualified to the
dhcp implementation
2) only "simple", known option types with a single no-repeating value
can be specified this
way (and data type is implied)(this would be enforced with the
"whitelist")
3) then implement separate elements for the complicated/repeating
options, e.g.:
<route destination='1.2.3.0' prefix='24' nextHop='192.168.122.5'/>
<route destination='1.2.4.0' prefix='24' nextHop='192.168.122.6'/>
...
<dnsServer address='10.1.1.1'/>
<dnsServer address='10.1.1.2'/>
Or maybe to simplify the parser this would work as:
<option name='classless-static-route' destination='1.2.3.0'
prefix='24' nextHop='192.168.122.5'/>
<option name='classless-static-route' destination='1.2.4.0'
prefix='24' nextHop='192.168.122.6'/>
...
<option name='dns-server address='10.1.1.1'/>
<option name='dns-server address='10.1.1.2'/>
Either of these definitely seems more compact and easy to understand
than all that ranting and raving at the top of this message...
Any other suggestions?
===
[1] https://bugzilla.redhat.com/show_bug.cgi?id=666556
[2] https://tools.ietf.org/rfc/rfc3397.txt
11 years, 7 months
[libvirt] Patch set to add InteractiveContainer support to virt-sandbox
by Dan Walsh
Resend of patches with lots of cleanups.
This patch set adds InteractiveContainer support to virt-sandbox-service
command. This is needed if we want to support the OpenShift model of
containers.
There are also some bug fix patches in the set.
[sandbox PATCH 01/15] virt-sandbox-service-util needs to free
[sandbox PATCH 02/15] Add support for InteractiveContainers to
[sandbox PATCH 03/15] Move virt-sandbox-service bash completion
[sandbox PATCH 04/15] Add -u UNITFILE option to virt-sandbox-service
[sandbox PATCH 05/15] Change virt-sandbox-service-create.pod to use
[sandbox PATCH 06/15] Internationalize all output strings in
[sandbox PATCH 07/15] Remove distinction from Internal vs External
[sandbox PATCH 08/15] Make CONFIG_PATH external to the Container
[sandbox PATCH 09/15] Add exception handler GlibGerror to
[sandbox PATCH 10/15] Change variable config to config_path to avoid
[sandbox PATCH 11/15] Refactor Container class into Container and
[sandbox PATCH 12/15] Add support for InteractiveContainer
[sandbox PATCH 13/15] Use args.uri rather then hard coding lxc:///
[sandbox PATCH 14/15] Check for LXC if virt-sandbox-service execute
[sandbox PATCH 15/15] Create new /etc/rc.d directory to bind mount
11 years, 7 months
[libvirt] [PATCH v3] util: Add a helper to check if all bits of a bitmap are clear
by Osier Yang
---
src/libvirt_private.syms | 1 +
src/util/virbitmap.c | 17 +++++++++++++++++
src/util/virbitmap.h | 3 +++
tests/virbitmaptest.c | 33 ++++++++++++++++++++++++++++++++-
4 files changed, 53 insertions(+), 1 deletion(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index b7b9631..6b831b3 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1046,6 +1046,7 @@ virBitmapEqual;
virBitmapFormat;
virBitmapFree;
virBitmapGetBit;
+virBitmapIsAllClear;
virBitmapIsAllSet;
virBitmapNew;
virBitmapNewCopy;
diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
index 21509ac..998c302 100644
--- a/src/util/virbitmap.c
+++ b/src/util/virbitmap.c
@@ -591,6 +591,23 @@ bool virBitmapIsAllSet(virBitmapPtr bitmap)
}
/**
+ * virBitmapIsAllClear:
+ * @bitmap: the bitmap to check
+ *
+ * check if all bits in @bitmap are clear
+ */
+bool virBitmapIsAllClear(virBitmapPtr bitmap)
+{
+ int i;
+
+ for (i = 0; i < bitmap->map_len; i++)
+ if (bitmap->map[i] != 0)
+ return false;
+
+ return true;
+}
+
+/**
* virBitmapNextSetBit:
* @bitmap: the bitmap
* @pos: the position after which to search for a set bit
diff --git a/src/util/virbitmap.h b/src/util/virbitmap.h
index 044c7a6..b682523 100644
--- a/src/util/virbitmap.h
+++ b/src/util/virbitmap.h
@@ -100,6 +100,9 @@ void virBitmapClearAll(virBitmapPtr bitmap)
bool virBitmapIsAllSet(virBitmapPtr bitmap)
ATTRIBUTE_NONNULL(1);
+bool virBitmapIsAllClear(virBitmapPtr bitmap)
+ ATTRIBUTE_NONNULL(1);
+
ssize_t virBitmapNextSetBit(virBitmapPtr bitmap, ssize_t pos)
ATTRIBUTE_NONNULL(1);
diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c
index 95d010a..3067f6e 100644
--- a/tests/virbitmaptest.c
+++ b/tests/virbitmaptest.c
@@ -125,6 +125,8 @@ static int test2(const void *data ATTRIBUTE_UNUSED)
goto error;
virBitmapClearAll(bitmap);
+ if (!virBitmapIsAllClear(bitmap))
+ goto error;
if (testBit(bitmap, 0, size - 1, false) < 0)
goto error;
if (virBitmapCountBits(bitmap) != 0)
@@ -154,6 +156,9 @@ static int test3(const void *data ATTRIBUTE_UNUSED)
if (!virBitmapIsAllSet(bitmap))
goto error;
+ virBitmapClearAll(bitmap);
+ if (!virBitmapIsAllClear(bitmap))
+ goto error;
ret = 0;
error:
@@ -196,6 +201,9 @@ static int test4(const void *data ATTRIBUTE_UNUSED)
if (virBitmapNextClearBit(bitmap, i) != -1)
goto error;
+ if (!virBitmapIsAllClear(bitmap))
+ goto error;
+
virBitmapFree(bitmap);
bitmap = NULL;
@@ -406,6 +414,10 @@ static int test7(const void *v ATTRIBUTE_UNUSED)
if (!virBitmapIsAllSet(bitmap))
goto error;
+ virBitmapClearAll(bitmap);
+ if (!virBitmapIsAllClear(bitmap))
+ goto error;
+
virBitmapFree(bitmap);
}
@@ -416,6 +428,24 @@ error:
return -1;
}
+static int test8(const void *v ATTRIBUTE_UNUSED)
+{
+ virBitmapPtr bitmap = NULL;
+ char data[108] = {0x00,};
+
+ bitmap = virBitmapNewData(data, sizeof(data));
+ if (!bitmap)
+ goto error;
+
+ if (!virBitmapIsAllClear(bitmap))
+ goto error;
+
+ return 0;
+error:
+ virBitmapFree(bitmap);
+ return -1;
+}
+
static int
mymain(void)
{
@@ -435,7 +465,8 @@ mymain(void)
ret = -1;
if (virtTestRun("test7", 1, test7, NULL) < 0)
ret = -1;
-
+ if (virtTestRun("test8", 1, test8, NULL) < 0)
+ ret = -1;
return ret;
}
--
1.8.1.4
11 years, 7 months
[libvirt] [PATCH v2] qemu: Support multiple queue virtio-scsi
by Osier Yang
This introduce a new attribute "num_queues" (same with the good name
QEMU uses) for virtio-scsi controller. An example of the XML:
<controller type='scsi' index='0' model='virtio-scsi' num_queues='8'/>
The corresponding QEMU command line:
-device virtio-scsi-pci,id=scsi0,num_queues=8,bus=pci.0,addr=0x3 \
---
docs/formatdomain.html.in | 18 +++++++++------
docs/schemas/domaincommon.rng | 5 +++++
src/conf/domain_conf.c | 13 +++++++++++
src/conf/domain_conf.h | 1 +
src/qemu/qemu_command.c | 11 +++++++++
.../qemuxml2argv-disk-virtio-scsi-num_queues.args | 8 +++++++
.../qemuxml2argv-disk-virtio-scsi-num_queues.xml | 26 ++++++++++++++++++++++
tests/qemuxml2argvtest.c | 3 +++
tests/qemuxml2xmltest.c | 1 +
9 files changed, 79 insertions(+), 7 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-num_queues.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-num_queues.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index cf382e8..2973ce2 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2092,13 +2092,17 @@
controller. A "scsi" controller has an optional
attribute <code>model</code>, which is one of "auto", "buslogic",
"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
- explicitly disabled for the guest, <code>model='none'</code> may be used.
- The PowerPC64 "spapr-vio" addresses do not have an associated controller.
+ "vmpvscsi". The attribute <code>num_queues</code>
+ (<span class="since">1.0.5 (QEMU and KVM only)</span>) is to specify
+ the number of queues for the controller, it's recommended to specify
+ the value matching the number of vCPUs for best performance. 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 explicitly disabled for the guest, <code>model='none'</code>
+ may be used. The PowerPC64 "spapr-vio" addresses do not have an
+ associated controller.
</p>
<p>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 63ba7d1..d486ae8 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1427,6 +1427,11 @@
</attribute>
</optional>
<optional>
+ <attribute name="num_queues">
+ <ref name="unsignedInt"/>
+ </attribute>
+ </optional>
+ <optional>
<ref name="usbmaster"/>
</optional>
<optional>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 5ad3080..f50a964 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5034,6 +5034,7 @@ virDomainControllerDefParseXML(xmlNodePtr node,
char *type = NULL;
char *idx = NULL;
char *model = NULL;
+ char *num_queues = NULL;
if (VIR_ALLOC(def) < 0) {
virReportOOMError();
@@ -5069,6 +5070,14 @@ virDomainControllerDefParseXML(xmlNodePtr node,
def->model = -1;
}
+ if ((num_queues = virXMLPropString(node, "num_queues"))) {
+ if (virStrToLong_ui(num_queues, NULL, 10, &def->num_queues) < 0) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("Malformed 'num_queues' value '%s'"), num_queues);
+ goto error;
+ }
+ }
+
if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0)
goto error;
@@ -5146,6 +5155,7 @@ cleanup:
VIR_FREE(type);
VIR_FREE(idx);
VIR_FREE(model);
+ VIR_FREE(num_queues);
return def;
@@ -13195,6 +13205,9 @@ virDomainControllerDefFormat(virBufferPtr buf,
virBufferEscapeString(buf, " model='%s'", model);
}
+ if (def->num_queues)
+ virBufferAsprintf(buf, " num_queues='%u'", def->num_queues);
+
switch (def->type) {
case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL:
if (def->opts.vioserial.ports != -1) {
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 700f03f..75e3f15 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -728,6 +728,7 @@ struct _virDomainControllerDef {
int type;
int idx;
int model; /* -1 == undef */
+ unsigned int num_queues;
union {
virDomainVirtioSerialOpts vioserial;
} opts;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 493e5f8..53caba5 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3533,6 +3533,14 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef,
virBuffer buf = VIR_BUFFER_INITIALIZER;
int model;
+ if (def->num_queues &&
+ !(def->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI &&
+ def->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("'num_queues' is only supported by virtio-scsi controller"));
+ return NULL;
+ }
+
switch (def->type) {
case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
model = def->model;
@@ -3616,6 +3624,9 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef,
goto error;
}
+ if (def->num_queues)
+ virBufferAsprintf(&buf, ",num_queues=%u", def->num_queues);
+
if (qemuBuildDeviceAddressStr(&buf, &def->info, qemuCaps) < 0)
goto error;
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-num_queues.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-num_queues.args
new file mode 100644
index 0000000..8d46799
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-num_queues.args
@@ -0,0 +1,8 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test \
+/usr/bin/qemu -S -M pc -m 214 -smp 8 -nographic -nodefconfig -nodefaults \
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \
+-device virtio-scsi-pci,id=scsi0,num_queues=8,bus=pci.0,addr=0x3 \
+-usb \
+-drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-scsi0-0-0-0 \
+-device scsi-disk,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-num_queues.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-num_queues.xml
new file mode 100644
index 0000000..dfa9cf1
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-num_queues.xml
@@ -0,0 +1,26 @@
+<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'>8</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='sdb' bus='scsi'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'/>
+ <controller type='scsi' index='0' model='virtio-scsi' num_queues='8'/>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 099fb36..d6575e7 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -553,6 +553,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-virtio-scsi-num_queues",
+ 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);
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index aa058bd..10a6ea2 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-virtio-scsi-num_queues");
DO_TEST("disk-scsi-megasas");
DO_TEST_FULL("disk-mirror", false, WHEN_ACTIVE);
DO_TEST_FULL("disk-mirror", true, WHEN_INACTIVE);
--
1.8.1.4
11 years, 7 months
[libvirt] [PATCH 0/3] Prohibit passing all clear cpumap for vcpupin/emulatorpin
by Osier Yang
*** NONE ***
Osier Yang (3):
util: Add a helper to check if all bits of a bitmap are clear
qemu: Error out if the bitmap for pinning is all clear
virsh: Prohibit all clear cpumap
src/libvirt_private.syms | 1 +
src/qemu/qemu_driver.c | 12 ++++++++++++
src/util/virbitmap.c | 30 ++++++++++++++++++++++++++++++
src/util/virbitmap.h | 3 +++
tools/virsh-domain.c | 35 ++++++++++++++++++++++++++++++-----
5 files changed, 76 insertions(+), 5 deletions(-)
--
1.8.1.4
11 years, 7 months