[libvirt] [PATCH for 1.2.7 0/8] Expose Expose IOMMU and VFIO host capabilities
by Michal Privoznik
After my RFC round, here are the actual patches.
Michal Privoznik (8):
Introduce domain_capabilities
Introduce virConnectGetDomainCapabilities
virsh: expose virConnectGetDomainCapabilities
tests: Move qemu caps XML parsing into shared unit
qemu_capabilities: Introduce virQEMUCapsCacheLookupByArch
qemu_capabilities: Introduce virQEMUCapsIsMachineSupported
qemu_capabilities: Introduce virQEMUCapsGetDefaultMachine
qemu: Implement virConnectGetDomainCapabilities
docs/formatdomaincaps.html.in | 200 ++++++++++++++++
docs/schemas/Makefile.am | 1 +
docs/schemas/domaincaps.rng | 90 ++++++++
docs/sitemap.html.in | 4 +
include/libvirt/libvirt.h.in | 7 +
libvirt.spec.in | 1 +
mingw-libvirt.spec.in | 2 +
po/POTFILES.in | 1 +
src/Makefile.am | 1 +
src/conf/domain_capabilities.c | 254 +++++++++++++++++++++
src/conf/domain_capabilities.h | 103 +++++++++
src/driver.h | 9 +
src/libvirt.c | 52 +++++
src/libvirt_private.syms | 8 +
src/libvirt_public.syms | 5 +
src/qemu/qemu_capabilities.c | 146 ++++++++++++
src/qemu/qemu_capabilities.h | 11 +
src/qemu/qemu_driver.c | 101 ++++++++
src/remote/remote_driver.c | 1 +
src/remote/remote_protocol.x | 19 +-
src/remote_protocol-structs | 11 +
tests/Makefile.am | 13 ++
tests/domaincapsschemadata/domaincaps-basic.xml | 10 +
tests/domaincapsschemadata/domaincaps-full.xml | 56 +++++
.../domaincaps-qemu_1.6.50-1.xml | 44 ++++
tests/domaincapsschematest | 11 +
tests/domaincapstest.c | 194 ++++++++++++++++
tests/qemucapabilitiestest.c | 57 +----
tests/testutilsqemu.c | 49 ++++
tests/testutilsqemu.h | 3 +
tools/virsh-host.c | 84 +++++++
tools/virsh.pod | 16 ++
32 files changed, 1509 insertions(+), 55 deletions(-)
create mode 100644 docs/formatdomaincaps.html.in
create mode 100644 docs/schemas/domaincaps.rng
create mode 100644 src/conf/domain_capabilities.c
create mode 100644 src/conf/domain_capabilities.h
create mode 100644 tests/domaincapsschemadata/domaincaps-basic.xml
create mode 100644 tests/domaincapsschemadata/domaincaps-full.xml
create mode 100644 tests/domaincapsschemadata/domaincaps-qemu_1.6.50-1.xml
create mode 100755 tests/domaincapsschematest
create mode 100644 tests/domaincapstest.c
--
1.8.5.5
10 years, 4 months
[libvirt] [PATCH v2] nwfilter: enum cleanups in "src/nwfilter/*"
by Julio Faracco
As we are doing with the enum structures, a cleanup in
"src/nwfilter/" directory was done now. All the enums that were
defined in the header files were converted to typedefs in this
directory. This patch includes all the adjustments to remove
conflicts when you do this kind of change. "Enum-to-typedef"'s
conversions were made in "src/nwfilter/nwfilter_{gentech_driver,
learnipaddr, tech_driver}.h".
Signed-off-by: Julio Faracco <jcfaracco(a)gmail.com>
---
src/nwfilter/nwfilter_gentech_driver.c | 12 ++++++------
src/nwfilter/nwfilter_gentech_driver.h | 4 ++--
src/nwfilter/nwfilter_learnipaddr.c | 8 ++++----
src/nwfilter/nwfilter_learnipaddr.h | 8 ++++----
src/nwfilter/nwfilter_tech_driver.h | 6 +++---
5 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter_gentech_driver.c
index 5bed106..e267cf1 100644
--- a/src/nwfilter/nwfilter_gentech_driver.c
+++ b/src/nwfilter/nwfilter_gentech_driver.c
@@ -332,7 +332,7 @@ static int
virNWFilterDefToInst(virNWFilterDriverStatePtr driver,
virNWFilterDefPtr def,
virNWFilterHashTablePtr vars,
- enum instCase useNewFilter,
+ virInstCase useNewFilter,
bool *foundNewFilter,
virNWFilterInstPtr inst);
@@ -374,7 +374,7 @@ static int
virNWFilterIncludeDefToRuleInst(virNWFilterDriverStatePtr driver,
virNWFilterIncludeDefPtr inc,
virNWFilterHashTablePtr vars,
- enum instCase useNewFilter,
+ virInstCase useNewFilter,
bool *foundNewFilter,
virNWFilterInstPtr inst)
{
@@ -464,7 +464,7 @@ static int
virNWFilterDefToInst(virNWFilterDriverStatePtr driver,
virNWFilterDefPtr def,
virNWFilterHashTablePtr vars,
- enum instCase useNewFilter,
+ virInstCase useNewFilter,
bool *foundNewFilter,
virNWFilterInstPtr inst)
{
@@ -630,7 +630,7 @@ virNWFilterInstantiate(const unsigned char *vmuuid ATTRIBUTE_UNUSED,
int ifindex,
const char *linkdev,
virNWFilterHashTablePtr vars,
- enum instCase useNewFilter, bool *foundNewFilter,
+ virInstCase useNewFilter, bool *foundNewFilter,
bool teardownOld,
const virMacAddr *macaddr,
virNWFilterDriverStatePtr driver,
@@ -782,7 +782,7 @@ __virNWFilterInstantiateFilter(virNWFilterDriverStatePtr driver,
const virMacAddr *macaddr,
const char *filtername,
virNWFilterHashTablePtr filterparams,
- enum instCase useNewFilter,
+ virInstCase useNewFilter,
bool forceWithPendingReq,
bool *foundNewFilter)
{
@@ -896,7 +896,7 @@ _virNWFilterInstantiateFilter(virNWFilterDriverStatePtr driver,
const unsigned char *vmuuid,
const virDomainNetDef *net,
bool teardownOld,
- enum instCase useNewFilter,
+ virInstCase useNewFilter,
bool *foundNewFilter)
{
const char *linkdev = (net->type == VIR_DOMAIN_NET_TYPE_DIRECT)
diff --git a/src/nwfilter/nwfilter_gentech_driver.h b/src/nwfilter/nwfilter_gentech_driver.h
index 8349ab4..4d14603 100644
--- a/src/nwfilter/nwfilter_gentech_driver.h
+++ b/src/nwfilter/nwfilter_gentech_driver.h
@@ -32,10 +32,10 @@ virNWFilterTechDriverPtr virNWFilterTechDriverForName(const char *name);
int virNWFilterTechDriversInit(bool privileged);
void virNWFilterTechDriversShutdown(void);
-enum instCase {
+typedef enum {
INSTANTIATE_ALWAYS,
INSTANTIATE_FOLLOW_NEWFILTER,
-};
+} virInstCase;
int virNWFilterInstantiateFilter(virNWFilterDriverStatePtr driver,
diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_learnipaddr.c
index 4cea9cf..ff73515 100644
--- a/src/nwfilter/nwfilter_learnipaddr.c
+++ b/src/nwfilter/nwfilter_learnipaddr.c
@@ -326,7 +326,7 @@ virNWFilterDeregisterLearnReq(int ifindex)
static void
procDHCPOpts(struct dhcp *dhcp, int dhcp_opts_len,
uint32_t *vmaddr, uint32_t *bcastaddr,
- enum howDetect *howDetected)
+ virHowDetect *howDetected)
{
struct dhcp_option *dhcpopt = &dhcp->options[0];
@@ -395,7 +395,7 @@ learnIPAddressThread(void *arg)
char *filter = NULL;
uint16_t etherType;
bool showError = true;
- enum howDetect howDetected = 0;
+ virHowDetect howDetected = 0;
virNWFilterTechDriverPtr techdriver = req->techdriver;
if (virNWFilterLockIface(req->ifname) < 0)
@@ -683,7 +683,7 @@ virNWFilterLearnIPAddress(virNWFilterTechDriverPtr techdriver,
const char *filtername,
virNWFilterHashTablePtr filterparams,
virNWFilterDriverStatePtr driver,
- enum howDetect howDetect)
+ virHowDetect howDetect)
{
int rc;
virNWFilterIPAddrLearnReqPtr req = NULL;
@@ -771,7 +771,7 @@ virNWFilterLearnIPAddress(virNWFilterTechDriverPtr techdriver ATTRIBUTE_UNUSED,
const char *filtername ATTRIBUTE_UNUSED,
virNWFilterHashTablePtr filterparams ATTRIBUTE_UNUSED,
virNWFilterDriverStatePtr driver ATTRIBUTE_UNUSED,
- enum howDetect howDetect ATTRIBUTE_UNUSED)
+ virHowDetect howdetect ATTRIBUTE_UNUSED)
{
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("IP parameter must be given since libvirt "
diff --git a/src/nwfilter/nwfilter_learnipaddr.h b/src/nwfilter/nwfilter_learnipaddr.h
index 1cc881a..19f8881 100644
--- a/src/nwfilter/nwfilter_learnipaddr.h
+++ b/src/nwfilter/nwfilter_learnipaddr.h
@@ -30,10 +30,10 @@
# include "nwfilter_tech_driver.h"
# include <net/if.h>
-enum howDetect {
+typedef enum {
DETECT_DHCP = 1,
DETECT_STATIC = 2,
-};
+} virHowDetect;
typedef struct _virNWFilterIPAddrLearnReq virNWFilterIPAddrLearnReq;
typedef virNWFilterIPAddrLearnReq *virNWFilterIPAddrLearnReqPtr;
@@ -46,7 +46,7 @@ struct _virNWFilterIPAddrLearnReq {
char *filtername;
virNWFilterHashTablePtr filterparams;
virNWFilterDriverStatePtr driver;
- enum howDetect howDetect;
+ virHowDetect howDetect;
int status;
pthread_t thread;
@@ -61,7 +61,7 @@ int virNWFilterLearnIPAddress(virNWFilterTechDriverPtr techdriver,
const char *filtername,
virNWFilterHashTablePtr filterparams,
virNWFilterDriverStatePtr driver,
- enum howDetect howDetect);
+ virHowDetect howDetect);
virNWFilterIPAddrLearnReqPtr virNWFilterLookupLearnReq(int ifindex);
int virNWFilterTerminateLearnReq(const char *ifname);
diff --git a/src/nwfilter/nwfilter_tech_driver.h b/src/nwfilter/nwfilter_tech_driver.h
index 7b6f56f..05d2561 100644
--- a/src/nwfilter/nwfilter_tech_driver.h
+++ b/src/nwfilter/nwfilter_tech_driver.h
@@ -70,13 +70,13 @@ typedef int (*virNWFilterRemoveBasicRules)(const char *ifname);
typedef int (*virNWFilterDropAllRules)(const char *ifname);
-enum techDrvFlags {
+typedef enum {
TECHDRV_FLAG_INITIALIZED = (1 << 0),
-};
+} techDrvFlags;
struct _virNWFilterTechDriver {
const char *name;
- enum techDrvFlags flags;
+ techDrvFlags flags;
virNWFilterTechDrvInit init;
virNWFilterTechDrvShutdown shutdown;
--
1.7.10.4
10 years, 4 months
[libvirt] [PATCH] qemu_domain: fix startup policy for disks
by Pavel Hrdina
https://bugzilla.redhat.com/show_bug.cgi?id=1086121
We now support startupPolicy='optional' for disks, but this
should work only for cold boot, not for restore or migrate.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/qemu/qemu_domain.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 9e38d02..a8cce76 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2230,11 +2230,16 @@ qemuDomainCheckDiskStartupPolicy(virQEMUDriverPtr driver,
{
char uuid[VIR_UUID_STRING_BUFLEN];
int startupPolicy = vm->def->disks[diskIndex]->startupPolicy;
+ int device = vm->def->disks[diskIndex]->device;
virUUIDFormat(vm->def->uuid, uuid);
switch ((virDomainStartupPolicy) startupPolicy) {
case VIR_DOMAIN_STARTUP_POLICY_OPTIONAL:
+ if (!cold_boot &&
+ device != VIR_DOMAIN_DISK_DEVICE_FLOPPY &&
+ device != VIR_DOMAIN_DISK_DEVICE_CDROM)
+ goto error;
break;
case VIR_DOMAIN_STARTUP_POLICY_MANDATORY:
--
1.8.5.5
10 years, 4 months
[libvirt] [PATCHv4 0/4] vbox: Rewrite vbox driver.
by Taowei
Use vboxUniformedAPI to rewrite vbox driver.
vboxInitialize and vboxDomainSave are rewrited
in this way.
Taowei (4):
add definitions for vboxUniformedAPI
implement vboxUniformedAPI in vbox_tmpl.c
use vboxUniformedAPI to generate common code
install vboxUniformedAPI
po/POTFILES.in | 1 +
src/Makefile.am | 4 +-
src/vbox/vbox_common.c | 150 +++++++++++++++
src/vbox/vbox_common.h | 151 +++++++++++++++
src/vbox/vbox_driver.c | 35 +++-
src/vbox/vbox_tmpl.c | 419 ++++++++++++++++++++++++-----------------
src/vbox/vbox_uniformed_api.h | 168 +++++++++++++++++
7 files changed, 749 insertions(+), 179 deletions(-)
create mode 100644 src/vbox/vbox_common.c
create mode 100644 src/vbox/vbox_common.h
create mode 100644 src/vbox/vbox_uniformed_api.h
--
1.7.9.5
10 years, 4 months
[libvirt] [PATCH] LXC: update comments of lxcDomainCreateXMLWithFiles() and lxcDomainCreateXML()
by Wang Rui
From: Yue wenyuan <yuewenyuan(a)huawei.com>
The comments for lxcDomainCreateXMLWithFiles are out of date. So update them.
And add comments for lxcDomainCreateXML
Signed-off-by: Wang Rui <moon.wangrui(a)huawei.com>
Signed-off-by: Yue wenyuan <yuewenyuan(a)huawei.com>
---
src/lxc/lxc_driver.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 06f3e18..11bfb80 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -1122,14 +1122,16 @@ static int lxcDomainCreateWithFlags(virDomainPtr dom,
}
/**
- * lxcDomainCreateXML:
+ * lxcDomainCreateXMLWithFiles:
* @conn: pointer to connection
+ * @nfiles: number of file descriptors passed
+ * @files: list of file descriptors passed
* @xml: XML definition of domain
* @flags: Must be 0 for now
*
* Creates a domain based on xml and starts it
*
- * Returns 0 on success or -1 in case of error
+ * Returns a new domain object or NULL in case of failure.
*/
static virDomainPtr
lxcDomainCreateXMLWithFiles(virConnectPtr conn,
@@ -1209,7 +1211,16 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn,
return dom;
}
-
+/**
+ * lxcDomainCreateXML:
+ * @conn: pointer to connection
+ * @xml: XML definition of domain
+ * @flags: Must be 0 for now
+ *
+ * Creates a domain based on xml and starts it
+ *
+ * Returns a new domain object or NULL in case of failure.
+ */
static virDomainPtr
lxcDomainCreateXML(virConnectPtr conn,
const char *xml,
--
1.7.12.4
10 years, 4 months
[libvirt] [PATCH] libxl: don't break the build on Xen>=4.5 because of libxl_vcpu_setaffinity()
by Dario Faggioli
libxl interface for vcpu pinning is changing in Xen 4.5. Basically,
libxl_set_vcpuaffinity() now wants one more parameter. That is
representative of 'VCPU soft affinity', which libvirt does not use.
To mark such change, the macro LIBXL_HAVE_VCPUINFO_SOFT_AFFINITY is
defined. Use it as a gate and, if present, re-#define the calls from
the old to the new interface, to avoid breaking the build.
Signed-off-by: Dario Faggioli <dario.faggioli(a)citrix.com>
Cc: Jim Fehlig <jfehlig(a)suse.com>
Cc: Ian Campbell <Ian.Campbell(a)citrix.com>
Cc: Ian Jackson <Ian.Jackson(a)eu.citrix.com>
---
src/libxl/libxl_conf.h | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h
index 6aa36d2..da66b4e 100644
--- a/src/libxl/libxl_conf.h
+++ b/src/libxl/libxl_conf.h
@@ -55,6 +55,17 @@
# define LIBXL_DUMP_DIR LIBXL_LIB_DIR "/dump"
# define LIBXL_BOOTLOADER_PATH BINDIR "/pygrub"
+/* libxl interface for setting VCPU affinity changed in 4.5. In fact, a new
+ * parameter has been added, representative of 'VCPU soft affinity'. If one
+ * does not care about it (and that's libvirt case), passing NULL is the
+ * right thing to do. To mark that change, LIBXL_HAVE_VCPUINFO_SOFT_AFFINITY
+ * is defined. */
+# ifdef LIBXL_HAVE_VCPUINFO_SOFT_AFFINITY
+# define libxl_set_vcpuaffinity(ctx, domid, vcpuid, map) \
+ libxl_set_vcpuaffinity((ctx), (domid), (vcpuid), (map), NULL)
+# define libxl_set_vcpuaffinity_all(ctx, domid, max_vcpus, map) \
+ libxl_set_vcpuaffinity_all((ctx), (domid), (max_vcpus), (map), NULL)
+# endif
typedef struct _libxlDriverPrivate libxlDriverPrivate;
typedef libxlDriverPrivate *libxlDriverPrivatePtr;
10 years, 4 months
[libvirt] [PATCHv3] Add invariant TSC cpu flag
by Ján Tomko
Add suport for invariant TSC flag (CPUID 0x80000007, bit 8 of EDX).
If this flag is enabled, the TSC ticks at a constant rate across
all ACPI P-, C- and T-states.
This can be enabled by adding:
<feature name='invtsc'/>
to the <cpu> element.
Migration and saving the domain does not work with this flag.
QEMU support for this is not merged yet:
https://lists.gnu.org/archive/html/qemu-devel/2014-04/msg05024.html
The feature name "invtsc" differs from the name "" used by the linux kernel:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/arch...
---
v1: https://www.redhat.com/archives/libvir-list/2014-May/msg00183.html
v2: https://www.redhat.com/archives/libvir-list/2014-May/msg00297.html
add it as a cpu flag instead of a timer
v3:
check if the feature wasn't filtered out on domain startup
src/cpu/cpu_map.xml | 5 +++++
src/qemu/qemu_migration.c | 14 ++++++++++++++
src/qemu/qemu_process.c | 15 +++++++++++++++
3 files changed, 34 insertions(+)
diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml
index 7d34d40..ffaeb92 100644
--- a/src/cpu/cpu_map.xml
+++ b/src/cpu/cpu_map.xml
@@ -327,6 +327,11 @@
<cpuid function='0x00000007' ebx='0x00100000'/>
</feature>
+ <!-- Advanced Power Management edx features -->
+ <feature name='invtsc'>
+ <cpuid function='0x80000007' edx='0x00000100'/>
+ </feature>
+
<!-- models -->
<model name='486'>
<feature name='fpu'/>
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index f0df1a6..7504a38 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1513,6 +1513,20 @@ qemuMigrationIsAllowed(virQEMUDriverPtr driver, virDomainObjPtr vm,
return false;
}
+ for (i = 0; i < def->cpu->nfeatures; i++) {
+ virCPUFeatureDefPtr feature = &def->cpu->features[i];
+
+ if (feature->policy != VIR_CPU_FEATURE_REQUIRE)
+ continue;
+
+ if (STREQ(feature->name, "invtsc")) {
+ virReportError(VIR_ERR_OPERATION_INVALID,
+ _("domain has CPU feature: %s"),
+ feature->name);
+ return false;
+ }
+ }
+
return true;
}
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index a83780f..0824afe 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3568,6 +3568,7 @@ qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver, virDomainObjPtr vm)
qemuDomainObjPrivatePtr priv = vm->privateData;
int rc;
bool ret = false;
+ size_t i;
switch (arch) {
case VIR_ARCH_I686:
@@ -3590,6 +3591,20 @@ qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver, virDomainObjPtr vm)
goto cleanup;
}
}
+
+ for (i = 0; i < def->cpu->nfeatures; i++) {
+ virCPUFeatureDefPtr feature = &def->cpu->features[i];
+
+ if (feature->policy != VIR_CPU_FEATURE_REQUIRE)
+ continue;
+
+ if (STREQ(feature->name, "invtsc") &&
+ !cpuHasFeature(guestcpu, feature->name)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("host doesn't support invariant TSC"));
+ goto cleanup;
+ }
+ }
break;
default:
--
1.8.3.2
10 years, 4 months
[libvirt] [PATCH] qemu: Add cmd_per_lun, max_sectors to virtio-scsi
by Mike Perez
This introduces two new attributes "cmd_per_lun" and "max_sectors" same
with the names QEMU uses for virtio-scsi. An example of the XML:
<controller type='scsi' index='0' model='virtio-scsi' cmd_per_lun='50'
max_sectors='512'/>
The corresponding QEMU command line:
-device virtio-scsi-pci,id=scsi0,cmd_per_lun=50,max_sectors=512,
bus=pci.0,addr=0x3
Signed-off-by: Mike Perez <thingee(a)gmail.com>
---
docs/formatdomain.html.in | 29 +++++++++++++++++++---
docs/schemas/domaincommon.rng | 10 ++++++++
src/conf/domain_conf.c | 27 ++++++++++++++++++--
src/conf/domain_conf.h | 2 ++
src/qemu/qemu_command.c | 27 ++++++++++++++++----
.../qemuxml2argv-disk-virtio-scsi-cmd_per_lun.args | 9 +++++++
.../qemuxml2argv-disk-virtio-scsi-cmd_per_lun.xml | 29 ++++++++++++++++++++++
.../qemuxml2argv-disk-virtio-scsi-max_sectors.args | 9 +++++++
.../qemuxml2argv-disk-virtio-scsi-max_sectors.xml | 29 ++++++++++++++++++++++
tests/qemuxml2argvtest.c | 6 +++++
tests/qemuxml2xmltest.c | 2 ++
11 files changed, 168 insertions(+), 11 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-cmd_per_lun.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-cmd_per_lun.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-max_sectors.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-max_sectors.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 691a451..8ffb247 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2559,11 +2559,32 @@
<p>
An optional sub-element <code>driver</code> can specify the driver
- specific options. Currently it only supports attribute <code>queues</code>
- (<span class="since">1.0.5</span>, QEMU and KVM only), which specifies the
- number of queues for the controller. For best performance, it's recommended
- to specify a value matching the number of vCPUs.
+ specific options:
</p>
+ <dl>
+ <dt><code>queues</code></dt>
+ <dd>
+ The optional <code>queues</code> attribute specifies the number of
+ queues for the controller. For best performance, it's recommended to
+ specify a value matching the number of vCPUs.
+ <span class="since">Since 1.0.5 (QEMU and KVM only)</span>
+ </dd>
+ <dt><code>cmd_per_lun</code></dt>
+ <dd>
+ The optional <code>cmd_per_lun</code> attribute specifies the maximum
+ number of commands that can be queued on devices controlled by the
+ host.
+ <span class="since">Since 1.2.5 (QEMU and KVM only)</span>
+ </dd>
+ <dt><code>max_sectors</code></dt>
+ <dd>
+ The optional <code>max_sectors</code> attribute specifies the maximum
+ amount of data in bytes that will be transferred to or from the device
+ in a single command. The transfer length is measured in sectors, where
+ a sector is 512 bytes.
+ <span class="since">Since 1.2.5 (QEMU and KVM only)</span>
+ </dd>
+ </dl>
<p>
USB companion controllers have an optional
sub-element <code><master></code> to specify the exact
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 4249ed5..4bf4699 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1735,6 +1735,16 @@
<ref name="unsignedInt"/>
</attribute>
</optional>
+ <optional>
+ <attribute name="cmd_per_lun">
+ <ref name="unsignedInt"/>
+ </attribute>
+ </optional>
+ <optional>
+ <attribute name="max_sectors">
+ <ref name="unsignedInt"/>
+ </attribute>
+ </optional>
</element>
</optional>
</interleave>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 40c385e..4388cb8 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6041,6 +6041,8 @@ virDomainControllerDefParseXML(xmlNodePtr node,
char *idx = NULL;
char *model = NULL;
char *queues = NULL;
+ char *cmd_per_lun = NULL;
+ char *max_sectors = NULL;
xmlNodePtr saved = ctxt->node;
int rc;
@@ -6084,6 +6086,8 @@ virDomainControllerDefParseXML(xmlNodePtr node,
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");
}
cur = cur->next;
}
@@ -6094,6 +6098,17 @@ virDomainControllerDefParseXML(xmlNodePtr node,
goto error;
}
+ if (cmd_per_lun && virStrToLong_ui(cmd_per_lun, NULL, 10, &def->cmd_per_lun) < 0) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("Malformed 'cmd_per_lun' value '%s'"), cmd_per_lun);
+ goto error;
+ }
+
+ if (max_sectors && virStrToLong_ui(max_sectors, NULL, 10, &def->max_sectors) < 0) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("Malformed 'max_sectors' value %s'"), max_sectors);
+ }
+
if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0)
goto error;
@@ -6201,6 +6216,8 @@ virDomainControllerDefParseXML(xmlNodePtr node,
VIR_FREE(idx);
VIR_FREE(model);
VIR_FREE(queues);
+ VIR_FREE(cmd_per_lun);
+ VIR_FREE(max_sectors);
return def;
@@ -15279,13 +15296,19 @@ virDomainControllerDefFormat(virBufferPtr buf,
break;
}
- if (def->queues || virDomainDeviceInfoIsSet(&def->info, flags) ||
- pcihole64) {
+ if (def->queues || def->cmd_per_lun || def->max_sectors ||
+ virDomainDeviceInfoIsSet(&def->info, flags) || pcihole64) {
virBufferAddLit(buf, ">\n");
virBufferAdjustIndent(buf, 2);
if (def->queues)
virBufferAsprintf(buf, "<driver queues='%u'/>\n", def->queues);
+ if (def->cmd_per_lun)
+ virBufferAsprintf(buf, "<driver cmd_per_lun='%u'/>\n", def->cmd_per_lun);
+
+ if (def->max_sectors)
+ virBufferAsprintf(buf, "<driver max_sectors='%u'/>\n", def->max_sectors);
+
if (virDomainDeviceInfoIsSet(&def->info, flags) &&
virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
return -1;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index bde303c..66484a1 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -720,6 +720,8 @@ struct _virDomainControllerDef {
unsigned int idx;
int model; /* -1 == undef */
unsigned int queues;
+ unsigned int cmd_per_lun;
+ unsigned int max_sectors;
union {
virDomainVirtioSerialOpts vioserial;
virDomainPCIControllerOpts pciopts;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 193959f..5274d17 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4236,12 +4236,23 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef,
virBuffer buf = VIR_BUFFER_INITIALIZER;
int model;
- if (def->queues &&
- !(def->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI &&
+ if (!(def->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI &&
def->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("'queues' is only supported by virtio-scsi controller"));
- return NULL;
+ if (def->queues) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("'queues' is only supported by virtio-scsi controller"));
+ return NULL;
+ }
+ if (def->cmd_per_lun) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("'cmd_per_lun' is only supported by virtio-scsi controller"));
+ return NULL;
+ }
+ if (def->max_sectors) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("'max_sectors' is only supported by virtio-scsi controller"));
+ return NULL;
+ }
}
switch (def->type) {
@@ -4369,6 +4380,12 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef,
if (def->queues)
virBufferAsprintf(&buf, ",num_queues=%u", def->queues);
+ if (def->cmd_per_lun)
+ virBufferAsprintf(&buf, ",cmd_per_lun=%u", def->cmd_per_lun);
+
+ if (def->max_sectors)
+ virBufferAsprintf(&buf, ",max_sectors=%u", def->max_sectors);
+
if (qemuBuildDeviceAddressStr(&buf, domainDef, &def->info, qemuCaps) < 0)
goto error;
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-cmd_per_lun.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-cmd_per_lun.args
new file mode 100644
index 0000000..2c75790
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-cmd_per_lun.args
@@ -0,0 +1,9 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/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,cmd_per_lun=50,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-cmd_per_lun.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-cmd_per_lun.xml
new file mode 100644
index 0000000..615a7f5
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-cmd_per_lun.xml
@@ -0,0 +1,29 @@
+<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'>
+ <driver cmd_per_lun='50'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-max_sectors.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-max_sectors.args
new file mode 100644
index 0000000..895f379
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-max_sectors.args
@@ -0,0 +1,9 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/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,max_sectors=512,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-max_sectors.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-max_sectors.xml
new file mode 100644
index 0000000..cd7d4a7
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-max_sectors.xml
@@ -0,0 +1,29 @@
+<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'>
+ <driver max_sectors='512'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 1ea7bf8..8ebb202 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -807,6 +807,12 @@ mymain(void)
DO_TEST("disk-virtio-scsi-num_queues",
QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
QEMU_CAPS_VIRTIO_SCSI);
+ DO_TEST("disk-virtio-scsi-cmd_per_lun",
+ QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
+ QEMU_CAPS_VIRTIO_SCSI);
+ DO_TEST("disk-virtio-scsi-max_sectors",
+ 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 da528da..73c4ff1 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -223,6 +223,8 @@ mymain(void)
DO_TEST("disk-scsi-vscsi");
DO_TEST("disk-scsi-virtio-scsi");
DO_TEST("disk-virtio-scsi-num_queues");
+ DO_TEST("disk-virtio-scsi-cmd_per_lun");
+ DO_TEST("disk-virtio-scsi-max_sectors");
DO_TEST("disk-scsi-megasas");
DO_TEST_FULL("disk-mirror", false, WHEN_ACTIVE);
DO_TEST_FULL("disk-mirror", true, WHEN_INACTIVE);
--
1.9.1
10 years, 4 months
[libvirt] [PATCH v1.2.[1-5]-maint] qemu: blockcopy: Don't remove existing disk mirror info
by Eric Blake
From: Peter Krempa <pkrempa(a)redhat.com>
When creating a new disk mirror the new struct is stored in a separate
variable until everything went well. The removed hunk would actually
remove existing mirror information for example when the api would be run
if a mirror still exists.
(cherry picked from commit 02b364e186d487f54ed410c01af042f23e812d42)
This fixes a regression introduced in commit ff5f30b.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
Conflicts:
src/qemu/qemu_driver.c - no refactoring of commit 7b7bf001
---
As Peter's patch resolves a regression, I'd like to backport it to
the maint branches; however, that means redoing the patch.
src/qemu/qemu_driver.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 59185c6..591864f 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -15203,6 +15203,7 @@ qemuDomainBlockCopy(virDomainObjPtr vm,
struct stat st;
bool need_unlink = false;
char *mirror = NULL;
+ int mirrorFormat;
virQEMUDriverConfigPtr cfg = NULL;
/* Preliminaries: find the disk we are editing, sanity checks */
@@ -15290,10 +15291,10 @@ qemuDomainBlockCopy(virDomainObjPtr vm,
goto endjob;
VIR_FORCE_CLOSE(fd);
if (!format)
- disk->mirrorFormat = disk->src.format;
+ mirrorFormat = disk->src.format;
} else if (format) {
- disk->mirrorFormat = virStorageFileFormatTypeFromString(format);
- if (disk->mirrorFormat <= 0) {
+ mirrorFormat = virStorageFileFormatTypeFromString(format);
+ if (mirrorFormat <= 0) {
virReportError(VIR_ERR_INVALID_ARG, _("unrecognized format '%s'"),
format);
goto endjob;
@@ -15303,11 +15304,11 @@ qemuDomainBlockCopy(virDomainObjPtr vm,
* also passed the RAW flag (and format is non-NULL), or it is
* safe for us to probe the format from the file that we will
* be using. */
- disk->mirrorFormat = virStorageFileProbeFormat(dest, cfg->user,
- cfg->group);
+ mirrorFormat = virStorageFileProbeFormat(dest, cfg->user,
+ cfg->group);
}
- if (!format && disk->mirrorFormat > 0)
- format = virStorageFileFormatTypeToString(disk->mirrorFormat);
+ if (!format && mirrorFormat > 0)
+ format = virStorageFileFormatTypeToString(mirrorFormat);
if (VIR_STRDUP(mirror, dest) < 0)
goto endjob;
@@ -15333,13 +15334,12 @@ qemuDomainBlockCopy(virDomainObjPtr vm,
/* Update vm in place to match changes. */
need_unlink = false;
disk->mirror = mirror;
+ disk->mirrorFormat = mirrorFormat;
mirror = NULL;
endjob:
if (need_unlink && unlink(dest))
VIR_WARN("unable to unlink just-created %s", dest);
- if (ret < 0 && disk)
- disk->mirrorFormat = VIR_STORAGE_FILE_NONE;
VIR_FREE(mirror);
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
--
1.9.3
10 years, 4 months
[libvirt] [PATCH 0/4] Report less errors
by Ján Tomko
Some are distracting and not really helpful.
Ján Tomko (4):
Track privileged state in udev nodedev driver
Only detect PCI Express devices as root in udev nodedev driver
Introduce virFileReadAllQuiet
Report one error less when getting net dev speed
src/libvirt_private.syms | 1 +
src/node_device/node_device_udev.c | 10 ++++++++--
src/util/virfile.c | 15 +++++++++++++++
src/util/virfile.h | 2 ++
src/util/virnetdev.c | 7 ++++---
5 files changed, 30 insertions(+), 5 deletions(-)
--
1.8.5.5
10 years, 4 months