[libvirt] [PATCH] Return error when updating cdrom device
by Pavel Hrdina
The commit 84c59ffa improved the way we change ejectable media.
If for any reason the first "eject" didn't open the tray we
should return with error.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/qemu/qemu_hotplug.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 125a2db..47ec779 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -125,6 +125,7 @@ int qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
/* If ret == -1, EjectMedia already set an error message */
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Unable to eject media"));
+ ret = -1;
}
goto audit;
}
--
1.8.5.5
10 years, 6 months
[libvirt] [PATCH] Fix crash in DAC driver with no seclabels
by Ján Tomko
With dynamic_ownership = 1 but no seclabels, RestoreChardevLabel
dereferences the NULL seclabel when checking if norelabel is set.
Remove this check, since it is already done in RestoreSecurityAllLabel
and if norelabel is set, RestoreChardevLabel is never called.
---
src/security/security_dac.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/src/security/security_dac.c b/src/security/security_dac.c
index 05303e7..00f47cb 100644
--- a/src/security/security_dac.c
+++ b/src/security/security_dac.c
@@ -768,22 +768,19 @@ virSecurityDACSetChardevLabel(virSecurityManagerPtr mgr,
static int
virSecurityDACRestoreChardevLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
- virDomainDefPtr def,
+ virDomainDefPtr def ATTRIBUTE_UNUSED,
virDomainChrDefPtr dev,
virDomainChrSourceDefPtr dev_source)
{
- virSecurityLabelDefPtr seclabel;
virSecurityDeviceLabelDefPtr chr_seclabel = NULL;
char *in = NULL, *out = NULL;
int ret = -1;
- seclabel = virDomainDefGetSecurityLabelDef(def, SECURITY_DAC_NAME);
-
if (dev)
chr_seclabel = virDomainChrDefGetSecurityLabelDef(dev,
SECURITY_DAC_NAME);
- if (seclabel->norelabel || (chr_seclabel && chr_seclabel->norelabel))
+ if (chr_seclabel && chr_seclabel->norelabel)
return 0;
switch ((enum virDomainChrType) dev_source->type) {
--
1.8.3.2
10 years, 6 months
[libvirt] libvirt build error in conf/domain_conf.c (Was: Re: [Xen-devel] [libvirt test] 26326: regressions - FAIL)
by Ian Campbell
On Sat, 2014-05-17 at 07:20 +0100, xen.org wrote:
> flight 26326 libvirt real [real]
> http://www.chiark.greenend.org.uk/~xensrcts/logs/26326/
>
> Regressions :-(
>
> Tests which did not succeed and are blocking,
> including tests which could not be run:
> build-amd64-libvirt 4 libvirt-build fail REGR. vs. 26314
> build-armhf-libvirt 4 libvirt-build fail REGR. vs. 26314
> build-i386-libvirt 4 libvirt-build fail REGR. vs. 26314
This is:
conf/domain_conf.c: In function 'virDomainDiskSourceParse':
conf/domain_conf.c:4992:9: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
conf/domain_conf.c:5015:21: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
conf/domain_conf.c: In function 'virDomainDiskBackingStoreParse':
conf/domain_conf.c:5113:5: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
(from http://www.chiark.greenend.org.uk/~xensrcts/logs/26326/build-amd64-libvir... )
I think this isn't Xen specific. I had a look at the recent traffic on
libvir-list and didn't see anything related so forwarding to
libvirt-list and Eric who seems to have touched the file in question in
the range.
Ian.
>
> Tests which did not succeed, but are not blocking:
> test-amd64-amd64-libvirt 1 xen-build-check(1) blocked n/a
> test-armhf-armhf-libvirt 1 xen-build-check(1) blocked n/a
> test-amd64-i386-libvirt 1 xen-build-check(1) blocked n/a
>
> version targeted for testing:
> libvirt d18aa7041699343d4df01cd9352e24f215b08c21
> baseline version:
> libvirt 5099084eb30c9c5454e79e8eab8bcff038c0f8cd
>
> ------------------------------------------------------------
> People who touched revisions under test:
> Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
> Eric Blake <eblake(a)redhat.com>
> Jiri Denemark <jdenemar(a)redhat.com>
> Michal Privoznik <mprivozn(a)redhat.com>
> ------------------------------------------------------------
>
> jobs:
> build-amd64 pass
> build-armhf pass
> build-i386 pass
> build-amd64-libvirt fail
> build-armhf-libvirt fail
> build-i386-libvirt fail
> build-amd64-oldkern pass
> build-i386-oldkern pass
> build-amd64-pvops pass
> build-armhf-pvops pass
> build-i386-pvops pass
> test-amd64-amd64-libvirt blocked
> test-armhf-armhf-libvirt blocked
> test-amd64-i386-libvirt blocked
>
>
> ------------------------------------------------------------
> sg-report-flight on osstest.cam.xci-test.com
> logs: /home/xc_osstest/logs
> images: /home/xc_osstest/images
>
> Logs, config files, etc. are available at
> http://www.chiark.greenend.org.uk/~xensrcts/logs
>
> Test harness code can be found at
> http://xenbits.xensource.com/gitweb?p=osstest.git;a=summary
>
>
> Not pushing.
>
> ------------------------------------------------------------
> commit d18aa7041699343d4df01cd9352e24f215b08c21
> Author: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
> Date: Tue May 13 16:01:16 2014 +0800
>
> util: fix memory leak in failure path of virCgroupKillRecursiveInternal
>
> Don't leak keypath when we fail to kill a process
>
> Signed-off-by: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
>
> commit b279e52f7bd07dfe6e7f5ef0b34f2b424c50eee2
> Author: Eric Blake <eblake(a)redhat.com>
> Date: Wed May 14 16:40:33 2014 -0600
>
> maint: prefer enum over int for virstoragefile structs
>
> For internal structs, we might as well be type-safe and let the
> compiler help us with less typing required on our part (getting
> rid of casts is always nice). In trying to use enums directly,
> I noticed two problems in virstoragefile.h that can't be fixed
> without more invasive refactoring: virStorageSource.format is
> used as more of a union of multiple enums in storage volume
> code (so it has to remain an int), and virStorageSourcePoolDef
> refers to pooltype whose enum is declared in src/conf, but where
> src/util can't pull in headers from src/conf.
>
> * src/util/virstoragefile.h (virStorageNetHostDef)
> (virStorageSourcePoolDef, virStorageSource): Use enums instead of
> int for fields of internal types.
> * src/qemu/qemu_command.c (qemuParseCommandLine): Cover all values.
> * src/conf/domain_conf.c (virDomainDiskSourceParse)
> (virDomainDiskSourceFormat): Simplify clients.
> * src/qemu/qemu_driver.c
> (qemuDomainSnapshotCreateSingleDiskActive)
> (qemuDomainSnapshotPrepareDiskExternalBackingInactive)
> (qemuDomainSnapshotPrepareDiskExternalOverlayActive)
> (qemuDomainSnapshotPrepareDiskInternal): Likewise.
>
> Signed-off-by: Eric Blake <eblake(a)redhat.com>
>
> commit ab5178188f250385132338e004d5c1f160fc5f34
> Author: Eric Blake <eblake(a)redhat.com>
> Date: Wed May 14 13:48:15 2014 -0600
>
> maint: shorten 'TypeType' function names
>
> The VIR_ENUM_DECL/VIR_ENUM_IMPL helper macros already append 'Type'
> to the enum name being converted; it looks silly to have functions
> with 'TypeType' in their name. Even though some of our enums have
> to have a 'Type' suffix, the corresponding string conversion
> functions do not.
>
> * src/conf/secret_conf.h (VIR_ENUM_DECL): Rename virSecretUsageType.
> * src/conf/storage_conf.h (VIR_ENUM_DECL): Rename
> virStoragePoolAuthType, virStoragePoolSourceAdapterType,
> virStoragePartedFsType.
> * src/conf/domain_conf.c (virDomainDiskDefParseXML)
> (virDomainFSDefParseXML, virDomainFSDefFormat): Update callers.
> * src/conf/secret_conf.c (virSecretDefParseUsage)
> (virSecretDefFormatUsage): Likewise.
> * src/conf/storage_conf.c (virStoragePoolDefParseAuth)
> (virStoragePoolDefParseSource, virStoragePoolSourceFormat):
> Likewise.
> * src/lxc/lxc_controller.c (virLXCControllerSetupLoopDevices):
> Likewise.
> * src/storage/storage_backend_disk.c
> (virStorageBackendDiskPartFormat): Likewise.
> * src/util/virstorageencryption.c (virStorageEncryptionSecretParse)
> (virStorageEncryptionSecretFormat): Likewise.
> * tools/virsh-secret.c (cmdSecretList): Likewise.
> * src/libvirt_private.syms (secret_conf.h, storage_conf.h): Export
> corrected names.
>
> Signed-off-by: Eric Blake <eblake(a)redhat.com>
>
> commit ea18f8b2b0337acfa418080d73035fac2185850b
> Author: Eric Blake <eblake(a)redhat.com>
> Date: Wed May 14 13:36:56 2014 -0600
>
> maint: use enum typedef for virstorageencryption.h
>
> Continuing the work of consistent enum cleanups; this time in
> virstorageencryption.h.
>
> * src/util/virstorageencryption.h (virStorageEncryptionFormat):
> Convert to typedef, renaming to avoid collision with function.
> (virStorageEncryptionSecret, virStorageEncryption): Directly use
> enums.
>
> Signed-off-by: Eric Blake <eblake(a)redhat.com>
>
> commit 3e44cf7fc60cdb45b899085b9c9c1eb1adafd097
> Author: Eric Blake <eblake(a)redhat.com>
> Date: Wed May 14 13:26:28 2014 -0600
>
> vbox: fix stale comment about vdi storage type
>
> The code had some todo's about adding 'vdi' to the list of
> virStorageType, but we've already done that.
>
> * src/vbox/vbox_tmpl.c (vboxStorageVolCreateXML)
> (vboxStorageVolGetXMLDesc): Use enum value for vdi type.
>
> Signed-off-by: Eric Blake <eblake(a)redhat.com>
>
> commit 6f9c75a6f7cbd18eea6c6d4df9ba74f9ddddcff6
> Author: Michal Privoznik <mprivozn(a)redhat.com>
> Date: Wed Apr 2 19:05:42 2014 +0200
>
> qemu: Implement virDomain{Get,Set}Time
>
> One caveat though, qemu-ga is expecting time and returning time
> in nanoseconds. With all the buffering and propagation delay, the
> time is already wrong once it gets to the qemu-ga, but there's
> nothing we can do about it.
>
> Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
>
> commit 222fdbfd2b852bd47d976a6305cc5cf4849824e0
> Author: Michal Privoznik <mprivozn(a)redhat.com>
> Date: Wed Apr 2 18:50:12 2014 +0200
>
> virsh: Expose virDomain{Get,Set}Time
>
> These APIs are exposed under new virsh command 'domtime' which both gets
> and sets (not at the same time of course :)).
>
> Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
>
> commit 0abb36938027f3991f3ce5151b31cca9737a1287
> Author: Michal Privoznik <mprivozn(a)redhat.com>
> Date: Wed Apr 2 18:25:07 2014 +0200
>
> Introduce virDomain{Get,Set}Time APIs
>
> These APIs allow users to get or set time in a domain, which may come
> handy if the domain has been resumed just recently and NTP is not
> configured or hasn't kicked in yet and the guest is running
> something time critical. In addition, NTP may refuse to re-set the clock
> if the skew is too big.
>
> In addition, new ACL attribute is introduced 'set_time'.
>
> Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
>
> commit a4693c76f5beb280869dac9d103ceb632c6c1403
> Author: Jiri Denemark <jdenemar(a)redhat.com>
> Date: Thu May 15 13:11:12 2014 +0200
>
> qemu: Avoid leak in qemuDomainCheckRemoveOptionalDisk
>
> Coverity complains about event being leaked in
> qemuDomainCheckRemoveOptionalDisk. The best fix for it is to remove the
> disk directly since we already know its index.
>
> Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel(a)lists.xen.org
> http://lists.xen.org/xen-devel
10 years, 6 months
[libvirt] [PATCH] Revert "maint: prefer enum over int for virstoragefile structs"
by Eric Blake
This partially reverts commits b279e52f7 and ea18f8b2.
It turns out our code base is full of:
if ((struct.member = virBlahFromString(str)) < 0)
goto error;
Meanwhile, the C standard says it is up to the compiler whether
an enum is signed or unsigned when all of its declared values
happen to be positive. In my testing (Fedora 20, gcc 4.8.2),
the compiler picked signed, and nothing changed. But others
testing with gcc 4.7 got compiler warnings, because it picked
the enum to be unsigned, but no unsigned value is less than 0.
Even worse:
if ((struct.member = virBlahFromString(str)) <= 0)
goto error;
is silently compiled without warning, but incorrectly treats -1
from a bad parse as a large positive number with no warning; and
without the compiler's help to find these instances, it is a
nightmare to maintain correctly. We could force signed enums
a dummy negative declaration in each enum, or cast the result of
virBlahFromString back to int after assigning to an enum value,
but that's uglier than what we were trying to cure by directly
using enum types for struct values. It's better off to just
live with int members, and use 'switch ((virFoo) struct.member)'
where we want the compiler to help, than to track down all the
conversions from string to enum and ensure they don't suffer
from type problems.
* src/util/virstorageencryption.h: Revert back to int declarations
with comment about enum usage.
* src/util/virstoragefile.h: Likewise.
* src/conf/domain_conf.c: Restore back to casts in switches.
* src/qemu/qemu_driver.c: Likewise.
* src/qemu/qemu_command.c: Add cast rather than revert.
---
src/conf/domain_conf.c | 4 ++--
src/qemu/qemu_command.c | 2 +-
src/qemu/qemu_driver.c | 8 ++++----
src/util/virstorageencryption.h | 4 ++--
src/util/virstoragefile.h | 14 +++++++-------
5 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e5ae7c6..e65b62b 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4972,7 +4972,7 @@ virDomainDiskSourceParse(xmlNodePtr node,
memset(&host, 0, sizeof(host));
- switch (src->type) {
+ switch ((virStorageType)src->type) {
case VIR_STORAGE_TYPE_FILE:
src->path = virXMLPropString(node, "file");
break;
@@ -14847,7 +14847,7 @@ virDomainDiskSourceFormat(virBufferPtr buf,
startupPolicy = virDomainStartupPolicyTypeToString(policy);
if (src->path || src->nhosts > 0 || src->srcpool || startupPolicy) {
- switch (src->type) {
+ switch ((virStorageType)src->type) {
case VIR_STORAGE_TYPE_FILE:
virBufferAddLit(buf, "<source");
virBufferEscapeString(buf, " file='%s'", src->path);
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 9ae1a96..193959f 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -11021,7 +11021,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
if (disk->src.type == VIR_STORAGE_TYPE_NETWORK) {
char *port;
- switch (disk->src.protocol) {
+ switch ((virStorageNetProtocol) disk->src.protocol) {
case VIR_STORAGE_NET_PROTOCOL_NBD:
if (qemuParseNBDString(disk) < 0)
goto error;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 55b4755..cab653b 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12368,7 +12368,7 @@ qemuDomainSnapshotPrepareDiskExternalBackingInactive(virDomainDiskDefPtr disk)
return 0;
case VIR_STORAGE_TYPE_NETWORK:
- switch (disk->src.protocol) {
+ switch ((virStorageNetProtocol) disk->src.protocol) {
case VIR_STORAGE_NET_PROTOCOL_NBD:
case VIR_STORAGE_NET_PROTOCOL_RBD:
case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG:
@@ -12430,7 +12430,7 @@ qemuDomainSnapshotPrepareDiskExternalOverlayActive(virDomainSnapshotDiskDefPtr d
return 0;
case VIR_STORAGE_TYPE_NETWORK:
- switch (disk->src.protocol) {
+ switch ((virStorageNetProtocol) disk->src.protocol) {
case VIR_STORAGE_NET_PROTOCOL_GLUSTER:
return 0;
@@ -12575,7 +12575,7 @@ qemuDomainSnapshotPrepareDiskInternal(virConnectPtr conn,
return 0;
case VIR_STORAGE_TYPE_NETWORK:
- switch (disk->src.protocol) {
+ switch ((virStorageNetProtocol) disk->src.protocol) {
case VIR_STORAGE_NET_PROTOCOL_NBD:
case VIR_STORAGE_NET_PROTOCOL_RBD:
case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG:
@@ -12801,7 +12801,7 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver,
VIR_STRDUP(persistSource, snap->src.path) < 0)
goto cleanup;
- switch (snap->src.type) {
+ switch ((virStorageType)snap->src.type) {
case VIR_STORAGE_TYPE_BLOCK:
reuse = true;
/* fallthrough */
diff --git a/src/util/virstorageencryption.h b/src/util/virstorageencryption.h
index 0a9bf44..f63c9ee 100644
--- a/src/util/virstorageencryption.h
+++ b/src/util/virstorageencryption.h
@@ -39,7 +39,7 @@ VIR_ENUM_DECL(virStorageEncryptionSecret)
typedef struct _virStorageEncryptionSecret virStorageEncryptionSecret;
typedef virStorageEncryptionSecret *virStorageEncryptionSecretPtr;
struct _virStorageEncryptionSecret {
- virStorageEncryptionSecretType type;
+ int type; /* virStorageEncryptionSecretType */
unsigned char uuid[VIR_UUID_BUFLEN];
};
@@ -55,7 +55,7 @@ VIR_ENUM_DECL(virStorageEncryptionFormat)
typedef struct _virStorageEncryption virStorageEncryption;
typedef virStorageEncryption *virStorageEncryptionPtr;
struct _virStorageEncryption {
- virStorageEncryptionFormatType format;
+ int format; /* virStorageEncryptionFormatType */
size_t nsecrets;
virStorageEncryptionSecretPtr *secrets;
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index 0a19603..ed7ab1b 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -150,7 +150,7 @@ typedef virStorageNetHostDef *virStorageNetHostDefPtr;
struct _virStorageNetHostDef {
char *name;
char *port;
- virStorageNetHostTransport transport;
+ int transport; /* virStorageNetHostTransport */
char *socket; /* path to unix socket */
};
@@ -182,10 +182,10 @@ typedef struct _virStorageSourcePoolDef virStorageSourcePoolDef;
struct _virStorageSourcePoolDef {
char *pool; /* pool name */
char *volume; /* volume name */
- virStorageVolType voltype; /* internal only */
+ int voltype; /* virStorageVolType, internal only */
int pooltype; /* virStoragePoolType from storage_conf.h, internal only */
- virStorageType actualtype; /* internal only */
- virStorageSourcePoolMode mode;
+ int actualtype; /* virStorageType, internal only */
+ int mode; /* virStorageSourcePoolMode */
};
typedef virStorageSourcePoolDef *virStorageSourcePoolDefPtr;
@@ -208,15 +208,15 @@ typedef virStorageSource *virStorageSourcePtr;
* backing chains, multiple source disks join to form a single guest
* view. */
struct _virStorageSource {
- virStorageType type;
+ int type; /* virStorageType */
char *path;
- virStorageNetProtocol protocol;
+ int protocol; /* virStorageNetProtocol */
size_t nhosts;
virStorageNetHostDefPtr hosts;
virStorageSourcePoolDefPtr srcpool;
struct {
char *username;
- virStorageSecretType secretType;
+ int secretType; /* virStorageSecretType */
union {
unsigned char uuid[VIR_UUID_BUFLEN];
char *usage;
--
1.9.0
10 years, 6 months
[libvirt] [PATCH v2] PCI: Introduce new device binding path using pci_dev.driver_override
by Alex Williamson
The driver_override field allows us to specify the driver for a device
rather than relying on the driver to provide a positive match of the
device. This shortcuts the existing process of looking up the vendor
and device ID, adding them to the driver new_id, binding the device,
then removing the ID, but it also provides a couple advantages.
First, the above existing process allows the driver to bind to any
device matching the new_id for the window where it's enabled. This is
often not desired, such as the case of trying to bind a single device
to a meta driver like pci-stub or vfio-pci. Using driver_override we
can do this deterministically using:
echo pci-stub > /sys/bus/pci/devices/0000:03:00.0/driver_override
echo 0000:03:00.0 > /sys/bus/pci/devices/0000:03:00.0/driver/unbind
echo 0000:03:00.0 > /sys/bus/pci/drivers_probe
Previously we could not invoke drivers_probe after adding a device
to new_id for a driver as we get non-deterministic behavior whether
the driver we intend or the standard driver will claim the device.
Now it becomes a deterministic process, only the driver matching
driver_override will probe the device.
To return the device to the standard driver, we simply clear the
driver_override and reprobe the device:
echo > /sys/bus/pci/devices/0000:03:00.0/driver_override
echo 0000:03:00.0 > /sys/bus/pci/devices/0000:03:00.0/driver/unbind
echo 0000:03:00.0 > /sys/bus/pci/drivers_probe
Another advantage to this approach is that we can specify a driver
override to force a specific binding or prevent any binding. For
instance when an IOMMU group is exposed to userspace through VFIO
we require that all devices within that group are owned by VFIO.
However, devices can be hot-added into an IOMMU group, in which case
we want to prevent the device from binding to any driver (override
driver = "none") or perhaps have it automatically bind to vfio-pci.
With driver_override it's a simple matter for this field to be set
internally when the device is first discovered to prevent driver
matches.
Signed-off-by: Alex Williamson <alex.williamson(a)redhat.com>
Cc: Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
---
v2: Use strchr() as suggested by Guenter Roeck and adopted by the
platform driver version of this same interface.
Documentation/ABI/testing/sysfs-bus-pci | 21 ++++++++++++++++
drivers/pci/pci-driver.c | 25 +++++++++++++++++--
drivers/pci/pci-sysfs.c | 40 +++++++++++++++++++++++++++++++
include/linux/pci.h | 1 +
4 files changed, 84 insertions(+), 3 deletions(-)
diff --git a/Documentation/ABI/testing/sysfs-bus-pci b/Documentation/ABI/testing/sysfs-bus-pci
index a3c5a66..898ddc4 100644
--- a/Documentation/ABI/testing/sysfs-bus-pci
+++ b/Documentation/ABI/testing/sysfs-bus-pci
@@ -250,3 +250,24 @@ Description:
valid. For example, writing a 2 to this file when sriov_numvfs
is not 0 and not 2 already will return an error. Writing a 10
when the value of sriov_totalvfs is 8 will return an error.
+
+What: /sys/bus/pci/devices/.../driver_override
+Date: April 2014
+Contact: Alex Williamson <alex.williamson(a)redhat.com>
+Description:
+ This file allows the driver for a device to be specified which
+ will override standard static and dynamic ID matching. When
+ specified, only a driver with a name matching the value written
+ to driver_override will have an opportunity to bind to the
+ device. The override is specified by writing a string to the
+ driver_override file (echo pci-stub > driver_override) and
+ may be cleared with an empty string (echo > driver_override).
+ This returns the device to standard matching rules binding.
+ Writing to driver_override does not automatically unbind the
+ device from its current driver or make any attempt to
+ automatically load the specified driver. If no driver with a
+ matching name is currently loaded in the kernel, the device
+ will not bind to any driver. This also allows devices to
+ opt-out of driver binding using a driver_override name such as
+ "none". Only a single driver may be specified in the override,
+ there is no support for parsing delimiters.
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index d911e0c..4393c12 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -216,6 +216,13 @@ const struct pci_device_id *pci_match_id(const struct pci_device_id *ids,
return NULL;
}
+static const struct pci_device_id pci_device_id_any = {
+ .vendor = PCI_ANY_ID,
+ .device = PCI_ANY_ID,
+ .subvendor = PCI_ANY_ID,
+ .subdevice = PCI_ANY_ID,
+};
+
/**
* pci_match_device - Tell if a PCI device structure has a matching PCI device id structure
* @drv: the PCI driver to match against
@@ -229,18 +236,30 @@ static const struct pci_device_id *pci_match_device(struct pci_driver *drv,
struct pci_dev *dev)
{
struct pci_dynid *dynid;
+ const struct pci_device_id *found_id = NULL;
+
+ /* When driver_override is set, only bind to the matching driver */
+ if (dev->driver_override && strcmp(dev->driver_override, drv->name))
+ return NULL;
/* Look at the dynamic ids first, before the static ones */
spin_lock(&drv->dynids.lock);
list_for_each_entry(dynid, &drv->dynids.list, node) {
if (pci_match_one_device(&dynid->id, dev)) {
- spin_unlock(&drv->dynids.lock);
- return &dynid->id;
+ found_id = &dynid->id;
+ break;
}
}
spin_unlock(&drv->dynids.lock);
- return pci_match_id(drv->id_table, dev);
+ if (!found_id)
+ found_id = pci_match_id(drv->id_table, dev);
+
+ /* driver_override will always match, send a dummy id */
+ if (!found_id && dev->driver_override)
+ found_id = &pci_device_id_any;
+
+ return found_id;
}
struct drv_dev_and_id {
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 4e0acef..faa4ab5 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -499,6 +499,45 @@ static struct device_attribute sriov_numvfs_attr =
sriov_numvfs_show, sriov_numvfs_store);
#endif /* CONFIG_PCI_IOV */
+static ssize_t driver_override_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct pci_dev *pdev = to_pci_dev(dev);
+ char *driver_override, *old = pdev->driver_override, *cp;
+
+ if (count > PATH_MAX)
+ return -EINVAL;
+
+ driver_override = kstrndup(buf, count, GFP_KERNEL);
+ if (!driver_override)
+ return -ENOMEM;
+
+ cp = strchr(driver_override, '\n');
+ if (cp)
+ *cp = '\0';
+
+ if (strlen(driver_override)) {
+ pdev->driver_override = driver_override;
+ } else {
+ kfree(driver_override);
+ pdev->driver_override = NULL;
+ }
+
+ kfree(old);
+
+ return count;
+}
+
+static ssize_t driver_override_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct pci_dev *pdev = to_pci_dev(dev);
+
+ return sprintf(buf, "%s\n", pdev->driver_override);
+}
+static DEVICE_ATTR_RW(driver_override);
+
static struct attribute *pci_dev_attrs[] = {
&dev_attr_resource.attr,
&dev_attr_vendor.attr,
@@ -521,6 +560,7 @@ static struct attribute *pci_dev_attrs[] = {
#if defined(CONFIG_PM_RUNTIME) && defined(CONFIG_ACPI)
&dev_attr_d3cold_allowed.attr,
#endif
+ &dev_attr_driver_override.attr,
NULL,
};
diff --git a/include/linux/pci.h b/include/linux/pci.h
index c7183be..a7a08f1 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -369,6 +369,7 @@ struct pci_dev {
#endif
phys_addr_t rom; /* Physical address of ROM if it's not from the BAR */
size_t romlen; /* Length of ROM if it's not from the BAR */
+ char *driver_override; /* Driver name to force a match */
};
static inline struct pci_dev *pci_physfn(struct pci_dev *dev)
10 years, 6 months
[libvirt] [PATCH 0/4] parallels: reimplement hard disks support
by Dmitry Guryanov
This patch series makes working with hard disks more natural
to the libvirt API. It removes all links between storage and
hypervisor driver, since only disks of type VIR_STORAGE_TYPE_VOLUME
should use information from storage driver.
Also it removes ability to create a VM where you want, because
it's not really needed. You only need the ability to create hard
disk images in the selected place.
Dmitry Guryanov (4):
parallels: add VIR_STORAGE_FILE_PLOOP format
parallels: set file format in virDomainDef
parallels: add disks correctly
parallels: create VMs in the default place
src/parallels/parallels_driver.c | 148 +++++++++------------------------------
src/util/virstoragefile.c | 4 +-
src/util/virstoragefile.h | 1 +
3 files changed, 37 insertions(+), 116 deletions(-)
--
1.9.0
10 years, 6 months
[libvirt] [PATCH] security_dac: Use virDomainTPMBackendType when possible
by Michal Privoznik
It's certainly useful to use enum typecast in switch().
Currently, it's not used only in two places:
virSecurityDACSetSecurityTPMFileLabel and
virSecurityDACRestoreSecurityTPMFileLabel.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/security/security_dac.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/security/security_dac.c b/src/security/security_dac.c
index 05303e7..7e0f160 100644
--- a/src/security/security_dac.c
+++ b/src/security/security_dac.c
@@ -847,7 +847,7 @@ virSecurityDACSetSecurityTPMFileLabel(virSecurityManagerPtr mgr,
{
int ret = 0;
- switch (tpm->type) {
+ switch ((enum virDomainTPMBackendType) tpm->type) {
case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
ret = virSecurityDACSetChardevLabel(mgr, def, NULL,
&tpm->data.passthrough.source);
@@ -867,7 +867,7 @@ virSecurityDACRestoreSecurityTPMFileLabel(virSecurityManagerPtr mgr,
{
int ret = 0;
- switch (tpm->type) {
+ switch ((enum virDomainTPMBackendType) tpm->type) {
case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
ret = virSecurityDACRestoreChardevLabel(mgr, def, NULL,
&tpm->data.passthrough.source);
--
1.9.3
10 years, 6 months
[libvirt] [PATCH] virSecurityDACRestoreSecurityHostdevLabel: Unmark @def as unused
by Michal Privoznik
The domain definition is clearly used a few lines
below so there's no need to mark @def as unused.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/security/security_dac.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/security/security_dac.c b/src/security/security_dac.c
index 289c2f0..05303e7 100644
--- a/src/security/security_dac.c
+++ b/src/security/security_dac.c
@@ -598,7 +598,7 @@ virSecurityDACRestoreSecuritySCSILabel(virSCSIDevicePtr dev ATTRIBUTE_UNUSED,
static int
virSecurityDACRestoreSecurityHostdevLabel(virSecurityManagerPtr mgr,
- virDomainDefPtr def ATTRIBUTE_UNUSED,
+ virDomainDefPtr def,
virDomainHostdevDefPtr dev,
const char *vroot)
--
1.9.3
10 years, 6 months
[libvirt] [PATCH v4 1/1] migration: add support for migrateURI configuration
by Chen Fan
For now, we set the migration URI via command line '--migrate_uri' or
construct the URI by looking up the dest host's hostname which could be
solved by DNS automatically.
But in cases the dest host have two or more NICs to reach, we may need to
send the migration data over a specific NIC which is different from the
automatically resloved one for some reason like performance, security, etc.
thus we must explicitly specify the migrateuri in command line everytime,
but it is too troublesome if there are many such hosts(and don't forget
virt-manager).
This patches add a configuration file option on dest host to save the
default migrate uri which explicitly specify which of this host's
addresses is used for transferring data, thus user doesn't boring
to specify it in command line everytime.
Signed-off-by: Chen Fan <chen.fan.fnst(a)cn.fujitsu.com>
---
v3-v4: move up the default uri_in setting to
qemuDomainMigratePrepare3Params()
src/qemu/qemu.conf | 6 +++++-
src/qemu/qemu_conf.c | 1 +
src/qemu/qemu_conf.h | 1 +
src/qemu/qemu_driver.c | 2 +-
4 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index f0e802f..6b443d0 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -449,7 +449,11 @@
#
#seccomp_sandbox = 1
-
+# Override the migration URI for specifying one of host's IP addresses
+# to transfer the migration data stream.
+# Defaults to hostname, both IPv4 and IPv6 addresses are accepted.
+#
+#migrate_uri = "tcp://192.168.0.1"
# Override the listen address for all incoming migrations. Defaults to
# 0.0.0.0, or :: if both host and qemu are capable of IPv6.
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 198ee2f..43361dc 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -574,6 +574,7 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
GET_VALUE_LONG("seccomp_sandbox", cfg->seccompSandbox);
+ GET_VALUE_STR("migrate_uri", cfg->migrateUri);
GET_VALUE_STR("migration_address", cfg->migrationAddress);
ret = 0;
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index a36ea63..f99c56e 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -163,6 +163,7 @@ struct _virQEMUDriverConfig {
int seccompSandbox;
+ char *migrateUri;
/* The default for -incoming */
char *migrationAddress;
int migrationPortMin;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index fca1a91..56c24b5 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -10888,7 +10888,7 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn,
virDomainDefPtr def = NULL;
const char *dom_xml = NULL;
const char *dname = NULL;
- const char *uri_in = NULL;
+ const char *uri_in = cfg->migrateUri;
const char *listenAddress = cfg->migrationAddress;
char *origname = NULL;
int ret = -1;
--
1.8.1.4
10 years, 6 months