[libvirt] [PATCH 0/2] Couple of small fixes
by Michal Privoznik
*** SOME BLURB HERE ***
Michal Privoznik (2):
nsstest: Drop useless @data check
testutils: Adapt to highly unlikely case
tests/nsstest.c | 3 ---
tests/testutils.c | 13 ++++++++++---
2 files changed, 10 insertions(+), 6 deletions(-)
--
2.7.3
8 years, 9 months
[libvirt] current master failed to compile
by Vasiliy Tolstov
libvirt.c:323:15: error: 'gcry_thread_cbs' is deprecated
[-Werror=deprecated-declarations]
static struct gcry_thread_cbs virTLSThreadImpl = {
^
In file included from libvirt.c:58:0:
/usr/x86_64-pc-linux-gnu/include/gcrypt.h:211:8: note: declared here
struct gcry_thread_cbs
^
libvirt.c:331:5: error: excess elements in struct initializer [-Werror]
virTLSMutexInit,
^
libvirt.c:331:5: note: (near initialization for 'virTLSThreadImpl')
libvirt.c:332:5: error: excess elements in struct initializer [-Werror]
virTLSMutexDestroy,
^
libvirt.c:332:5: note: (near initialization for 'virTLSThreadImpl')
libvirt.c:333:5: error: excess elements in struct initializer [-Werror]
virTLSMutexLock,
^
libvirt.c:333:5: note: (near initialization for 'virTLSThreadImpl')
libvirt.c:334:5: error: excess elements in struct initializer [-Werror]
virTLSMutexUnlock,
^
libvirt.c:334:5: note: (near initialization for 'virTLSThreadImpl')
my configure line is:
./configure --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu
--prefix=/usr/x86_64-pc-linux-gnu
--bindir=/usr/x86_64-pc-linux-gnu/bin
--sbindir=/usr/x86_64-pc-linux-gnu/bin
--libdir=/usr/x86_64-pc-linux-gnu/lib --datadir=/usr/share
--datarootdir=/usr/share --docdir=/usr/share/doc/libvirt-scm
--infodir=/usr/share/info --mandir=/usr/share/man --sysconfdir=/etc
--localstatedir=/var/lib --disable-dependency-tracking
--disable-silent-rules --enable-fast-install --enable-nls
--localstatedir=/var --with-blkid --with-chrdev-lock-files=/run/lock
--with-curl --with-dbus --with-firewalld --with-gnutls
--with-html-dir=/usr/share/doc/libvirt-scm --with-html-subdir=./
--with-init-script=systemd --with-interface --with-libvirtd
--with-macvtap --with-pciaccess --with-qemu-group=kvm --with-readline
--with-remote --with-secrets --with-ssh2 --with-storage-dir
--with-storage-fs --with-sysctl --with-test --with-udev
--with-virtualport --without-apparmor --without-apparmor-mount
--without-apparmor-profiles --without-audit --without-driver-modules
--without-dtrace --without-esx --without-hal --without-hyperv
--without-included-regex --without-libxl --without-netcf
--without-openvz --without-openwsman --without-phyp
--without-rhel5-api --without-sanlock --without-secdriver-apparmor
--without-secdriver-selinux --without-selinux --without-selinux-mount
--without-storage-gluster --without-storage-rbd --without-storage-zfs
--without-vz --without-xen --without-xen-inotify --without-xenapi
--enable-debug --without-avahi --with-attr --without-storage-iscsi
--with-qemu --with-yajl --with-capng --without-storage-lvm
--without-storage-mpath --with-lxc --with-fuse --without-network
--without-numactl --without-numad --without-libpcap --without-pm-utils
--without-polkit --without-storage-disk --without-sasl
--without-storage-scsi --without-storage-sheepdog --without-uml
--without-vbox --without-vmware --without-wireshark-dissector
--
Vasiliy Tolstov,
e-mail: v.tolstov(a)selfip.ru
8 years, 9 months
[libvirt] [PATCH 0/3] Couple of coverity fixes
by Michal Privoznik
These all have been spotted by coverity.
Michal Privoznik (3):
event-test: Use goto cleanup instead of if else jungle
event-test: Check for virConnectRegisterCloseCallback return value
gendispatch: Avoid comparing signed and unsigned vars
examples/object-events/event-test.c | 138 +++++++++++++++++++-----------------
src/rpc/gendispatch.pl | 2 +-
2 files changed, 75 insertions(+), 65 deletions(-)
--
2.4.10
8 years, 9 months
[libvirt] [PATCH v6 0/4] ARM: add query-gic-capabilities SMP command
by Peter Xu
v6 changes:
- patch 1 (squashed into patch 2)
- explain more about the following in commit message: why we need
this command, and what does the entries mean [Markus]
- explain what GIC is [Eric]
- squash this patch into patch 2 [Eric]
- patch 2 (new patch 1)
- fix "does not implement" english error [Eric]
- remove useless headers in target-arm/monitor.c [Markus]
- remove this command from whitelist [Markus, Eric]
- return dict rather than array, with single key points to the
original array results [Markus, Eric]
- patch 5 (new patch 4)
- tiny change in implementation to suite the new interface.
v5 changes:
- patch 2: moved to target-arm/monitor.c (from target-arm/machine.c)
[Peter]
- patch 3: splitted into three patches: [all from Peter's comments]
- patch 3 (new): leverage kvm_arm_create_scratch_host_vcpu(), tiny
enhancement of old one to suite our need
- patch 4: introduce kvm_support_device() in kvm-all.c
- patch 5: do the implementation.
v4 changes:
- all: rename query-gic-capability to query-gic-capabilities [Andrea]
- patch 3: rename helper function to kvm_support_device, make it
inline and lighter. [Drew]
v3 changes:
- patch 2: remove func declaration, add qmp header [Drew]
- patch 3: being able to detect KVM GIC capabilities even without
kvm enabled [Andrea]: this is a little bit hacky, need some more
review on this.
v2 changes:
- result layout change: use array and dict for the capability bits
rather than a single array of strings [Andrea/Markus]
- spelling out what GIC is in doc [Eric]
This patch is to add ARM-specific command "query-gic-capability".
The new command can report which kind of GIC device the host/QEMU
support. The returned result is in the form of array.
Sample command and output:
{"execute": "query-gic-capability"}
{"return": [{"emulated": false, "version": 3, "kernel": false},
{"emulated": true, "version": 2, "kernel": true}]}
Testing:
Smoke tests on both x86 (emulated) and another moonshot ARM server.
Peter Xu (4):
arm: qmp: add query-gic-capabilities interface
arm: enhance kvm_arm_create_scratch_host_vcpu
kvm: add kvm_support_device() helper function
arm: implement query-gic-capabilities
include/sysemu/kvm.h | 9 +++++
kvm-all.c | 15 +++++++++
monitor.c | 8 +++++
qapi-schema.json | 50 ++++++++++++++++++++++++++++
qmp-commands.hx | 28 ++++++++++++++++
target-arm/Makefile.objs | 2 +-
target-arm/kvm.c | 10 +++++-
target-arm/kvm_arm.h | 6 ++--
target-arm/monitor.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++
9 files changed, 210 insertions(+), 4 deletions(-)
create mode 100644 target-arm/monitor.c
--
2.4.3
8 years, 9 months
[libvirt] [PATCH] remote: Fix error message
by Cole Robinson
We were printing the wrong MAX value
---
Pushed as trivial
daemon/remote.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index 2bf9e83..3bf94fa 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -5724,11 +5724,11 @@ remoteDispatchConnectGetAllDomainStats(virNetServerPtr server ATTRIBUTE_UNUSED,
if (nrecords > REMOTE_CONNECT_GET_ALL_DOMAIN_STATS_MAX) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Number of domain stats records is %d, "
"which exceeds max limit: %d"),
- nrecords, REMOTE_DOMAIN_LIST_MAX);
+ nrecords, REMOTE_CONNECT_GET_ALL_DOMAIN_STATS_MAX);
goto cleanup;
}
if (nrecords) {
if (VIR_ALLOC_N(ret->retStats.retStats_val, nrecords) < 0)
--
2.5.0
8 years, 9 months
[libvirt] Block replication driver
by Simon Kollberg
Hi!
I'm working on supporting a new FT/HA solution for qemu called COLO
(http://wiki.qemu.org/Features/COLO). The part that is currently being
focused
on for libvirt integration is Block Replication
(http://wiki.qemu.org/Features/BlockReplication) which enables guest state
synchronization for disks.
Right now there are three issues that I'd like to get your input on:
1.
As you can see on the block replication wiki-page we need to reference the
secondary disk id.
Example from the wiki:
-drive if=none,driver=raw,file.filename=1.raw,id=colo1 \
-drive if=xxx,driver=replication,mode=secondary,\
...
file.backing.backing=colo1
My initial thought was to manually set the alias of the
disk and add a new reference element to the backingStore:
<disk type='file' device='disk'>
...
<alias name='colo1'/>
</disk>
<disk type='file' device='disk'>
...
<backingStore type='file'>
...
<reference name='colo1'/>
</backingStore>
</disk>
Though, I quickly realized that setting the alias is only done by the
hypervisor and is therefore not an option with the current code.
Would it be bad letting the user set the alias, and if so, do you have any
ideas of how to solve the referencing?
2.
The format of the disk and the driver type currently shares the same
attribute in libvirt (the type attribute on driver XML element). However,
with
the new replication disk driver you need to be able to set both the disk
format
and also the driver name.
Example from the wiki:
-drive if=xxx,driver=replication,mode=secondary,\
file.file.filename=active_disk.qcow2,\
file.driver=qcow2,\
...
I saw that there was a function in libvirt called virStorageFileProbeFormat
that could let us get the format of the disk without stating it in the XML.
But
as I'm sure you know, it's strongly advised not to be used since you can
trick
the function by modifying the disk file.
3.
When using the replication driver the secondary disk is supposed to be added
but not attached.
Example from the wiki:
-drive if=none,driver=raw,file.filename=1.raw,id=colo1 \
-drive if=xxx,driver=replication,mode=secondary,\
...
Clearly, trying to setup a disk without a target is not allowed at the
moment.
Is there any better way of doing it?
Any comments and insights in general are also greatly appreciated!
/Simon
8 years, 9 months
[libvirt] [PATCH lxc_ethernet] lxc:support network type with ethernet
by zhongguocheng1@163.com
From: z00209963 <z00209963(a)szxbz472.huaweiobz.com>
---
src/lxc/lxc_process.c | 35 +++++++++++++++++++++++++++++++++++
src/lxc/lxc_process.h | 3 +++
2 files changed, 38 insertions(+)
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index 57e3880..1ffd9ac 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -359,6 +359,38 @@ char *virLXCProcessSetupInterfaceDirect(virConnectPtr conn,
return ret;
}
+char *virLXCProcessSetupInterfaceEthernet(virDomainDefPtr vm,
+ virDomainNetDefPtr net)
+{
+ char *ret = NULL;
+ char *parentVeth;
+ char *containerVeth = NULL;
+
+ VIR_DEBUG("calling vethCreate()");
+ parentVeth = net->ifname;
+ if (virNetDevVethCreate(&parentVeth, &containerVeth) < 0)
+ goto cleanup;
+ VIR_DEBUG("parentVeth: %s, containerVeth: %s", parentVeth, containerVeth);
+
+ if (net->ifname == NULL)
+ net->ifname = parentVeth;
+
+ if (virNetDevSetMAC(containerVeth, &net->mac) < 0)
+ goto cleanup;
+
+ if (virNetDevSetOnline(parentVeth, true) < 0)
+ goto cleanup;
+
+ if (net->filter &&
+ virDomainConfNWFilterInstantiate(vm->uuid, net) < 0)
+ goto cleanup;
+
+ ret = containerVeth;
+
+ cleanup:
+ return ret;
+}
+
static const char *nsInfoLocal[VIR_LXC_DOMAIN_NAMESPACE_LAST] = {
[VIR_LXC_DOMAIN_NAMESPACE_SHARENET] = "net",
[VIR_LXC_DOMAIN_NAMESPACE_SHAREIPC] = "ipc",
@@ -559,6 +591,9 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn,
break;
case VIR_DOMAIN_NET_TYPE_ETHERNET:
+ if (!(veth = virLXCProcessSetupInterfaceEthernet(def,
+ net)))
+ goto cleanup;
break;
case VIR_DOMAIN_NET_TYPE_USER:
diff --git a/src/lxc/lxc_process.h b/src/lxc/lxc_process.h
index b6c8083..cc8e707 100644
--- a/src/lxc/lxc_process.h
+++ b/src/lxc/lxc_process.h
@@ -53,5 +53,8 @@ char *virLXCProcessSetupInterfaceBridged(virDomainDefPtr vm,
char *virLXCProcessSetupInterfaceDirect(virConnectPtr conn,
virDomainDefPtr def,
virDomainNetDefPtr net);
+char *virLXCProcessSetupInterfaceEthernet(virDomainDefPtr vm,
+ virDomainNetDefPtr net);
+
#endif /* __LXC_PROCESS_H__ */
--
2.5.1.windows.1
8 years, 9 months
[libvirt] [RFC PATCH] hostdev: add support for "managed='detach'"
by Laine Stump
Suggested by Alex Williamson.
If you plan to assign a GPU to a virtual machine, but that GPU happens
to be the host system console, you likely want it to start out using
the host driver (so that boot messages/etc will be displayed), then
later have the host driver replaced with vfio-pci for assignment to
the virtual machine.
However, in at least some cases (e.g. Intel i915) once the device has
been detached from the host driver and attached to vfio-pci, attempts
to reattach to the host driver only lead to "grief" (ask Alex for
details). This means that simply using "managed='yes'" in libvirt
won't work.
And if you set "managed='no'" in libvirt then either you have to
manually run virsh nodedev-detach prior to the first start of the
guest, or you have to have a management application intelligent enough
to know that it should detach from the host driver, but never reattach
to it.
This patch makes it simple/automatic to deal with such a case - it
adds a third "managed" mode for assigned PCI devices, called
"detach". It will detach ("unbind" in driver parlance) the device from
the host driver prior to assigning it to the guest, but when the guest
is finished with the device, will leave it bound to vfio-pci. This
allows re-using the device for another guest, without requiring
initial out-of-band intervention to unbind the host driver.
---
I'm sending this with the "RFC" tag because I'm concerned it might be
considered "feature creep" by some (although I think it makes at least
as much sense as "managed='yes'") and also because, even once (if) it
is ACKed, I wouldn't want to push it until abologna is finished
hacking around with the driver bind/unbind code - he has enough grief
to deal with without me causing a bunch of merge conflicts :-)
docs/formatdomain.html.in | 29 ++++++++++++-----
docs/schemas/basictypes.rng | 8 +++++
docs/schemas/domaincommon.rng | 4 +--
docs/schemas/network.rng | 2 +-
src/conf/domain_conf.c | 21 +++++++-----
src/conf/domain_conf.h | 2 +-
src/conf/network_conf.c | 18 +++++------
src/conf/network_conf.h | 5 +--
src/libvirt_private.syms | 2 ++
src/network/bridge_driver.c | 2 +-
src/qemu/qemu_parse_command.c | 4 +--
src/util/virhostdev.c | 10 +++---
src/util/virpci.c | 14 +++++---
src/util/virpci.h | 14 ++++++--
src/xenconfig/xen_common.c | 3 +-
src/xenconfig/xen_sxpr.c | 9 +++---
tests/networkxml2xmlin/hostdev-managed-detach.xml | 10 ++++++
tests/networkxml2xmlout/hostdev-managed-detach.xml | 10 ++++++
tests/networkxml2xmltest.c | 1 +
.../qemuxml2argv-hostdev-managed-detach.args | 22 +++++++++++++
.../qemuxml2argv-hostdev-managed-detach.xml | 30 ++++++++++++++++++
tests/qemuxml2argvtest.c | 3 ++
.../qemuxml2xmlout-hostdev-managed-detach.xml | 37 ++++++++++++++++++++++
tests/qemuxml2xmltest.c | 1 +
tests/virhostdevtest.c | 8 ++---
25 files changed, 215 insertions(+), 54 deletions(-)
create mode 100644 tests/networkxml2xmlin/hostdev-managed-detach.xml
create mode 100644 tests/networkxml2xmlout/hostdev-managed-detach.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-managed-detach.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-managed-detach.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-hostdev-managed-detach.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 41f2488..a732c1c 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -3323,15 +3323,28 @@
hot-unplugged.
</dd>
<dt>pci</dt>
- <dd>For PCI devices, when <code>managed</code> is "yes" it is
- detached from the host before being passed on to the guest
- and reattached to the host after the guest exits. If
+ <dd>For PCI devices, when <code>managed</code> is "yes" it
+ is detached from the host driver (and attached to the
+ appropriate driver for the planned type of device
+ assignment, e.g. vfio-pci for VFIO, pci-stub for legacy
+ kvm, or pciback for Xen device passthrough) before being
+ passed to the guest, and reattached to the host driver
+ after the guest exits. If <code>managed</code> is
+ "detach", then the device is detached from the host driver
+ before passing to the guest, but is left attached to
+ vfio-pci or pci-stub when the guest exits. If
<code>managed</code> is omitted or "no", the user is
- responsible to call <code>virNodeDeviceDetachFlags</code>
- (or <code>virsh nodedev-detach</code> before starting the guest
- or hot-plugging the device and <code>virNodeDeviceReAttach</code>
- (or <code>virsh nodedev-reattach</code>) after hot-unplug or
- stopping the guest.
+ responsible for assuring that the device is attached to
+ the proper driver for the desired device assignment mode
+ before starting the guest or hot-plugging the device. This
+ can be done in the libvirt API with
+ <code>virNodeDeviceDetachFlags</code> (or by running
+ <code>virsh nodedev-detach</code>). Likewise, once the
+ guest is finished using the device, it will be up to the
+ user to re-attach it to the host driver (if that is
+ desired), or example by using
+ libvirt's <code>virNodeDeviceReAttach</code> API or
+ running <code>virsh nodedev-reattach</code>.
</dd>
<dt>scsi</dt>
<dd>For SCSI devices, user is responsible to make sure the device
diff --git a/docs/schemas/basictypes.rng b/docs/schemas/basictypes.rng
index a83063a..50ba9c7 100644
--- a/docs/schemas/basictypes.rng
+++ b/docs/schemas/basictypes.rng
@@ -88,6 +88,14 @@
</optional>
</define>
+ <define name="virPCIManagedMode">
+ <choice>
+ <value>no</value>
+ <value>yes</value>
+ <value>detach</value>
+ </choice>
+ </define>
+
<!-- a 6 byte MAC address in ASCII-hex format, eg "12:34:56:78:9A:BC" -->
<!-- The lowest bit of the 1st byte is the "multicast" bit. a -->
<!-- uniMacAddr requires that bit to be 0, and a multiMacAddr -->
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 8c6287d..3701f4f 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2241,7 +2241,7 @@
</attribute>
<optional>
<attribute name="managed">
- <ref name="virYesNo"/>
+ <ref name="virPCIManagedMode"/>
</attribute>
</optional>
<interleave>
@@ -3756,7 +3756,7 @@
</optional>
<optional>
<attribute name="managed">
- <ref name="virYesNo"/>
+ <ref name="virPCIManagedMode"/>
</attribute>
</optional>
<choice>
diff --git a/docs/schemas/network.rng b/docs/schemas/network.rng
index 4edb6eb..f5e049b 100644
--- a/docs/schemas/network.rng
+++ b/docs/schemas/network.rng
@@ -112,7 +112,7 @@
<optional>
<attribute name="managed">
- <ref name="virYesNo"/>
+ <ref name="virPCIManagedMode"/>
</attribute>
</optional>
<interleave>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7d68096..2332b69 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -39,6 +39,7 @@
#include "viruuid.h"
#include "virbuffer.h"
#include "virlog.h"
+#include "virpci.h"
#include "nwfilter_conf.h"
#include "storage_conf.h"
#include "virstoragefile.h"
@@ -5599,9 +5600,11 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
* element that might be (pure hostdev, or higher level device
* (e.g. <interface>) with type='hostdev')
*/
- if ((managed = virXMLPropString(node, "managed")) != NULL) {
- if (STREQ(managed, "yes"))
- def->managed = true;
+ if ((managed = virXMLPropString(node, "managed")) &&
+ (def->managed = virPCIManagedModeTypeFromString(managed)) < 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown managed mode '%s'"), managed);
+ goto error;
}
sgio = virXMLPropString(node, "sgio");
@@ -19808,8 +19811,9 @@ virDomainActualNetDefFormat(virBufferPtr buf,
virBufferAsprintf(buf, "<actual type='%s'", typeStr);
if (type == VIR_DOMAIN_NET_TYPE_HOSTDEV) {
virDomainHostdevDefPtr hostdef = virDomainNetGetActualHostdev(def);
- if (hostdef && hostdef->managed)
- virBufferAddLit(buf, " managed='yes'");
+ if (hostdef && (hostdef->managed != VIR_PCI_MANAGED_NO))
+ virBufferAsprintf(buf, " managed='%s'",
+ virPCIManagedModeTypeToString(hostdef->managed));
}
if (def->trustGuestRxFilters)
virBufferAsprintf(buf, " trustGuestRxFilters='%s'",
@@ -19979,8 +19983,9 @@ virDomainNetDefFormat(virBufferPtr buf,
}
virBufferAsprintf(buf, "<interface type='%s'", typeStr);
- if (hostdef && hostdef->managed)
- virBufferAddLit(buf, " managed='yes'");
+ if (hostdef && (hostdef->managed != VIR_PCI_MANAGED_NO))
+ virBufferAsprintf(buf, " managed='%s'",
+ virPCIManagedModeTypeToString(hostdef->managed));
if (def->trustGuestRxFilters)
virBufferAsprintf(buf, " trustGuestRxFilters='%s'",
virTristateBoolTypeToString(def->trustGuestRxFilters));
@@ -21430,7 +21435,7 @@ virDomainHostdevDefFormat(virBufferPtr buf,
mode, type);
if (def->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) {
virBufferAsprintf(buf, " managed='%s'",
- def->managed ? "yes" : "no");
+ virPCIManagedModeTypeToString(def->managed));
if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI &&
scsisrc->sgio)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 85c4f55..42c7d36 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -543,7 +543,7 @@ struct _virDomainHostdevDef {
virDomainDeviceDef parent; /* higher level Def containing this */
int mode; /* enum virDomainHostdevMode */
int startupPolicy; /* enum virDomainStartupPolicy */
- bool managed;
+ int managed; /* enum virPCIManagedMode */
bool missing;
bool readonly;
bool shareable;
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 4fb2e2a..a40f3e0 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -1,7 +1,7 @@
/*
* network_conf.c: network XML handling
*
- * Copyright (C) 2006-2015 Red Hat, Inc.
+ * Copyright (C) 2006-2016 Red Hat, Inc.
* Copyright (C) 2006-2008 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -43,6 +43,7 @@
#include "virbuffer.h"
#include "c-ctype.h"
#include "virfile.h"
+#include "virpci.h"
#include "virstring.h"
#define VIR_FROM_THIS VIR_FROM_NETWORK
@@ -1825,10 +1826,11 @@ virNetworkForwardDefParseXML(const char *networkName,
VIR_FREE(type);
}
- forwardManaged = virXPathString("string(./@managed)", ctxt);
- if (forwardManaged != NULL &&
- STRCASEEQ(forwardManaged, "yes")) {
- def->managed = true;
+ if ((forwardManaged = virXPathString("string(./@managed)", ctxt)) &&
+ (def->managed = virPCIManagedModeTypeFromString(forwardManaged)) < 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown managed mode '%s'"), forwardManaged);
+ goto cleanup;
}
forwardDriverName = virXPathString("string(./driver/@name)", ctxt);
@@ -2723,10 +2725,8 @@ virNetworkDefFormatBuf(virBufferPtr buf,
virBufferEscapeString(buf, " dev='%s'", dev);
virBufferAsprintf(buf, " mode='%s'", mode);
if (def->forward.type == VIR_NETWORK_FORWARD_HOSTDEV) {
- if (def->forward.managed)
- virBufferAddLit(buf, " managed='yes'");
- else
- virBufferAddLit(buf, " managed='no'");
+ virBufferAsprintf(buf, " managed='%s'",
+ virPCIManagedModeTypeToString(def->forward.managed));
}
shortforward = !(def->forward.nifs || def->forward.npfs
|| VIR_SOCKET_ADDR_VALID(&def->forward.addr.start)
diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h
index b72257b..3b86781 100644
--- a/src/conf/network_conf.h
+++ b/src/conf/network_conf.h
@@ -1,7 +1,7 @@
/*
* network_conf.h: network XML handling
*
- * Copyright (C) 2006-2015 Red Hat, Inc.
+ * Copyright (C) 2006-2016 Red Hat, Inc.
* Copyright (C) 2006-2008 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -187,7 +187,8 @@ typedef struct _virNetworkForwardDef virNetworkForwardDef;
typedef virNetworkForwardDef *virNetworkForwardDefPtr;
struct _virNetworkForwardDef {
int type; /* One of virNetworkForwardType constants */
- bool managed; /* managed attribute for hostdev mode */
+ int managed; /* managed attribute for hostdev mode */
+ /* enum virPCIManagedMode */
int driverName; /* enum virNetworkForwardDriverNameType */
/* If there are multiple forward devices (i.e. a pool of
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 55c3047..3dd00ec 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2010,6 +2010,8 @@ virPCIGetVirtualFunctionIndex;
virPCIGetVirtualFunctionInfo;
virPCIGetVirtualFunctions;
virPCIIsVirtualFunction;
+virPCIManagedModeTypeFromString;
+virPCIManagedModeTypeToString;
virPCIStubDriverTypeFromString;
virPCIStubDriverTypeToString;
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 01c2ed6..bd1f57c 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -4085,7 +4085,7 @@ networkAllocateActualDevice(virDomainDefPtr dom,
iface->data.network.actual->data.hostdev.def.parent.data.net = iface;
iface->data.network.actual->data.hostdev.def.info = &iface->info;
iface->data.network.actual->data.hostdev.def.mode = VIR_DOMAIN_HOSTDEV_MODE_SUBSYS;
- iface->data.network.actual->data.hostdev.def.managed = netdef->forward.managed ? 1 : 0;
+ iface->data.network.actual->data.hostdev.def.managed = netdef->forward.managed;
iface->data.network.actual->data.hostdev.def.source.subsys.type = dev->type;
iface->data.network.actual->data.hostdev.def.source.subsys.u.pci.addr = dev->device.pci;
diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c
index 60e3d69..060bf66 100644
--- a/src/qemu/qemu_parse_command.c
+++ b/src/qemu/qemu_parse_command.c
@@ -1192,7 +1192,7 @@ qemuParseCommandLinePCI(const char *val)
}
def->mode = VIR_DOMAIN_HOSTDEV_MODE_SUBSYS;
- def->managed = true;
+ def->managed = VIR_PCI_MANAGED_YES;
def->source.subsys.type = VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI;
def->source.subsys.u.pci.addr.bus = bus;
def->source.subsys.u.pci.addr.slot = slot;
@@ -1255,7 +1255,7 @@ qemuParseCommandLineUSB(const char *val)
}
def->mode = VIR_DOMAIN_HOSTDEV_MODE_SUBSYS;
- def->managed = false;
+ def->managed = VIR_PCI_MANAGED_NO;
def->source.subsys.type = VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB;
if (*end == '.') {
usbsrc->bus = first;
diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index 098207e..4baf884 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -1,6 +1,6 @@
/* virhostdev.c: hostdev management
*
- * Copyright (C) 2006-2007, 2009-2015 Red Hat, Inc.
+ * Copyright (C) 2006-2007, 2009-2016 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange
* Copyright (C) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
*
@@ -592,7 +592,7 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr hostdev_mgr,
for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
- if (virPCIDeviceGetManaged(dev)) {
+ if (virPCIDeviceGetManaged(dev) != VIR_PCI_MANAGED_NO) {
VIR_DEBUG("Detaching managed PCI device %s",
virPCIDeviceGetName(dev));
if (virPCIDeviceDetach(dev,
@@ -726,7 +726,7 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr hostdev_mgr,
for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
- if (virPCIDeviceGetManaged(dev)) {
+ if (virPCIDeviceGetManaged(dev) == VIR_PCI_MANAGED_YES) {
VIR_DEBUG("Reattaching managed PCI device %s",
virPCIDeviceGetName(dev));
ignore_value(virPCIDeviceReattach(dev,
@@ -756,7 +756,7 @@ virHostdevReattachPCIDevice(virPCIDevicePtr dev, virHostdevManagerPtr mgr)
/* If the device is not managed and was attached to guest
* successfully, it must have been inactive.
*/
- if (!virPCIDeviceGetManaged(dev)) {
+ if (virPCIDeviceGetManaged(dev) != VIR_PCI_MANAGED_YES) {
VIR_DEBUG("Adding unmanaged PCI device %s to inactive list",
virPCIDeviceGetName(dev));
if (virPCIDeviceListAdd(mgr->inactivePCIHostdevs, dev) < 0)
@@ -1312,7 +1312,7 @@ virHostdevPrepareSCSIHostDevices(virDomainHostdevDefPtr hostdev,
virSCSIDevicePtr scsi;
int ret = -1;
- if (hostdev->managed) {
+ if (hostdev->managed != VIR_PCI_MANAGED_NO) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("SCSI host device doesn't support managed mode"));
goto cleanup;
diff --git a/src/util/virpci.c b/src/util/virpci.c
index 1854318..7164824 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -1,7 +1,7 @@
/*
* virpci.c: helper APIs for managing host PCI devices
*
- * Copyright (C) 2009-2015 Red Hat, Inc.
+ * Copyright (C) 2009-2016 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -62,6 +62,11 @@ VIR_ENUM_IMPL(virPCIStubDriver, VIR_PCI_STUB_DRIVER_LAST,
"vfio-pci", /* VFIO */
);
+VIR_ENUM_IMPL(virPCIManagedMode, VIR_PCI_MANAGED_LAST,
+ "no",
+ "yes",
+ "detach");
+
struct _virPCIDevice {
virPCIDeviceAddress address;
@@ -77,7 +82,7 @@ struct _virPCIDevice {
unsigned int pci_pm_cap_pos;
bool has_flr;
bool has_pm_reset;
- bool managed;
+ virPCIManagedMode managed;
virPCIStubDriver stubDriver;
@@ -1702,12 +1707,13 @@ virPCIDeviceGetName(virPCIDevicePtr dev)
return dev->name;
}
-void virPCIDeviceSetManaged(virPCIDevicePtr dev, bool managed)
+void virPCIDeviceSetManaged(virPCIDevicePtr dev,
+ virPCIManagedMode managed)
{
dev->managed = managed;
}
-bool
+virPCIManagedMode
virPCIDeviceGetManaged(virPCIDevicePtr dev)
{
return dev->managed;
diff --git a/src/util/virpci.h b/src/util/virpci.h
index 55329c8..1969e29 100644
--- a/src/util/virpci.h
+++ b/src/util/virpci.h
@@ -53,6 +53,16 @@ typedef enum {
VIR_ENUM_DECL(virPCIStubDriver);
typedef enum {
+ VIR_PCI_MANAGED_NO,
+ VIR_PCI_MANAGED_YES,
+ VIR_PCI_MANAGED_DETACH,
+
+ VIR_PCI_MANAGED_LAST
+} virPCIManagedMode;
+
+VIR_ENUM_DECL(virPCIManagedMode);
+
+typedef enum {
VIR_PCIE_LINK_SPEED_NA = 0,
VIR_PCIE_LINK_SPEED_25,
VIR_PCIE_LINK_SPEED_5,
@@ -98,8 +108,8 @@ int virPCIDeviceReset(virPCIDevicePtr dev,
virPCIDeviceListPtr inactiveDevs);
void virPCIDeviceSetManaged(virPCIDevice *dev,
- bool managed);
-bool virPCIDeviceGetManaged(virPCIDevice *dev);
+ virPCIManagedMode managed);
+virPCIManagedMode virPCIDeviceGetManaged(virPCIDevice *dev);
void virPCIDeviceSetStubDriver(virPCIDevicePtr dev,
virPCIStubDriver driver);
virPCIStubDriver virPCIDeviceGetStubDriver(virPCIDevicePtr dev);
diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c
index 828c8e9..db4745c 100644
--- a/src/xenconfig/xen_common.c
+++ b/src/xenconfig/xen_common.c
@@ -32,6 +32,7 @@
#include "virerror.h"
#include "virconf.h"
#include "viralloc.h"
+#include "virpci.h"
#include "viruuid.h"
#include "count-one-bits.h"
#include "xenxs_private.h"
@@ -461,7 +462,7 @@ xenParsePCI(virConfPtr conf, virDomainDefPtr def)
if (!(hostdev = virDomainHostdevDefAlloc()))
return -1;
- hostdev->managed = false;
+ hostdev->managed = VIR_PCI_MANAGED_NO;
hostdev->source.subsys.type = VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI;
hostdev->source.subsys.u.pci.addr.domain = domainID;
hostdev->source.subsys.u.pci.addr.bus = busID;
diff --git a/src/xenconfig/xen_sxpr.c b/src/xenconfig/xen_sxpr.c
index fdfec2b..51b32a4 100644
--- a/src/xenconfig/xen_sxpr.c
+++ b/src/xenconfig/xen_sxpr.c
@@ -1,7 +1,7 @@
/*
* xen_sxpr.c: Xen SEXPR parsing functions
*
- * Copyright (C) 2010-2014 Red Hat, Inc.
+ * Copyright (C) 2010-2014, 2016 Red Hat, Inc.
* Copyright (C) 2011 Univention GmbH
* Copyright (C) 2005 Anthony Liguori <aliguori(a)us.ibm.com>
*
@@ -32,6 +32,7 @@
#include "virerror.h"
#include "virconf.h"
#include "viralloc.h"
+#include "virpci.h"
#include "verify.h"
#include "viruuid.h"
#include "virlog.h"
@@ -1114,7 +1115,7 @@ xenParseSxprPCI(virDomainDefPtr def,
goto error;
dev->mode = VIR_DOMAIN_HOSTDEV_MODE_SUBSYS;
- dev->managed = false;
+ dev->managed = VIR_PCI_MANAGED_NO;
dev->source.subsys.type = VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI;
dev->source.subsys.u.pci.addr.domain = domainID;
dev->source.subsys.u.pci.addr.bus = busID;
@@ -2002,7 +2003,7 @@ xenFormatSxprOnePCI(virDomainHostdevDefPtr def,
virBufferPtr buf,
int detach)
{
- if (def->managed) {
+ if (def->managed != VIR_PCI_MANAGED_NO) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("managed PCI devices not supported with XenD"));
return -1;
@@ -2062,7 +2063,7 @@ xenFormatSxprAllPCI(virDomainDefPtr def,
for (i = 0; i < def->nhostdevs; i++) {
if (def->hostdevs[i]->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
def->hostdevs[i]->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) {
- if (def->hostdevs[i]->managed) {
+ if (def->hostdevs[i]->managed != VIR_PCI_MANAGED_NO) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("managed PCI devices not supported with XenD"));
return -1;
diff --git a/tests/networkxml2xmlin/hostdev-managed-detach.xml b/tests/networkxml2xmlin/hostdev-managed-detach.xml
new file mode 100644
index 0000000..3a5fac4
--- /dev/null
+++ b/tests/networkxml2xmlin/hostdev-managed-detach.xml
@@ -0,0 +1,10 @@
+<network>
+ <name>hostdev</name>
+ <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
+ <forward mode='hostdev' managed='detach'>
+ <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x1'/>
+ <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x2'/>
+ <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x3'/>
+ <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x4'/>
+ </forward>
+</network>
diff --git a/tests/networkxml2xmlout/hostdev-managed-detach.xml b/tests/networkxml2xmlout/hostdev-managed-detach.xml
new file mode 100644
index 0000000..3a5fac4
--- /dev/null
+++ b/tests/networkxml2xmlout/hostdev-managed-detach.xml
@@ -0,0 +1,10 @@
+<network>
+ <name>hostdev</name>
+ <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
+ <forward mode='hostdev' managed='detach'>
+ <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x1'/>
+ <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x2'/>
+ <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x3'/>
+ <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x4'/>
+ </forward>
+</network>
diff --git a/tests/networkxml2xmltest.c b/tests/networkxml2xmltest.c
index 8d60aa8..ec9a47f 100644
--- a/tests/networkxml2xmltest.c
+++ b/tests/networkxml2xmltest.c
@@ -108,6 +108,7 @@ mymain(void)
DO_TEST("openvswitch-net");
DO_TEST_FULL("passthrough-pf", VIR_NETWORK_XML_INACTIVE);
DO_TEST("hostdev");
+ DO_TEST("hostdev-managed-detach");
DO_TEST_FULL("hostdev-pf", VIR_NETWORK_XML_INACTIVE);
DO_TEST("passthrough-address-crash");
DO_TEST("nat-network-explicit-flood");
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-managed-detach.args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-managed-detach.args
new file mode 100644
index 0000000..9e37ed5
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-managed-detach.args
@@ -0,0 +1,22 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu \
+-name QEMUGuestManagedUnbind \
+-S \
+-M pc \
+-m 214 \
+-smp 1 \
+-uuid c7a5fdbd-edaf-9466-926a-d65c16db1809 \
+-nographic \
+-nodefconfig \
+-nodefaults \
+-monitor unix:/tmp/lib/domain--1-QEMUGuestManagedUnbi/monitor.sock,server,nowait \
+-no-acpi \
+-boot c \
+-usb \
+-device vfio-pci,host=06:12.5,id=hostdev0,bus=pci.0,addr=0x3 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-managed-detach.xml b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-managed-detach.xml
new file mode 100644
index 0000000..2d12d98
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-managed-detach.xml
@@ -0,0 +1,30 @@
+<domain type='qemu'>
+ <name>QEMUGuestManagedUnbind</name>
+ <uuid>c7a5fdbd-edaf-9466-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' 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>
+ <controller type='usb' index='0'/>
+ <controller type='ide' index='0'/>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <hostdev mode='subsystem' type='pci' managed='detach'>
+ <driver name='vfio'/>
+ <source>
+ <address domain='0x0000' bus='0x06' slot='0x12' function='0x5'/>
+ </source>
+ </hostdev>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index e15da37..433e3a7 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1278,6 +1278,9 @@ mymain(void)
DO_TEST_FAILURE("hostdev-vfio-multidomain",
QEMU_CAPS_PCIDEVICE,
QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VFIO_PCI);
+ DO_TEST("hostdev-managed-detach",
+ QEMU_CAPS_PCIDEVICE, QEMU_CAPS_NODEFCONFIG,
+ QEMU_CAPS_DEVICE_VFIO_PCI);
DO_TEST("pci-rom",
QEMU_CAPS_PCIDEVICE, QEMU_CAPS_NODEFCONFIG,
QEMU_CAPS_PCI_ROMBAR);
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-hostdev-managed-detach.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-hostdev-managed-detach.xml
new file mode 100644
index 0000000..e639e91
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-hostdev-managed-detach.xml
@@ -0,0 +1,37 @@
+<domain type='qemu'>
+ <name>QEMUGuestManagedUnbind</name>
+ <uuid>c7a5fdbd-edaf-9466-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' 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>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <hostdev mode='subsystem' type='pci' managed='detach'>
+ <driver name='vfio'/>
+ <source>
+ <address domain='0x0000' bus='0x06' slot='0x12' function='0x5'/>
+ </source>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </hostdev>
+ <memballoon model='virtio'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+ </memballoon>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 0735677..980c468 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -484,6 +484,7 @@ mymain(void)
DO_TEST("hostdev-usb-address");
DO_TEST("hostdev-pci-address");
DO_TEST("hostdev-vfio");
+ DO_TEST("hostdev-managed-detach");
DO_TEST("pci-rom");
DO_TEST("pci-serial-dev-chardev");
diff --git a/tests/virhostdevtest.c b/tests/virhostdevtest.c
index 5eb2e7e..af175ca 100644
--- a/tests/virhostdevtest.c
+++ b/tests/virhostdevtest.c
@@ -166,7 +166,7 @@ testVirHostdevPreparePCIHostdevs_unmanaged(void)
size_t active_count, inactive_count, i;
for (i = 0; i < nhostdevs; i++)
- hostdevs[i]->managed = false;
+ hostdevs[i]->managed = VIR_PCI_MANAGED_NO;
active_count = virPCIDeviceListCount(mgr->activePCIHostdevs);
inactive_count = virPCIDeviceListCount(mgr->inactivePCIHostdevs);
@@ -225,7 +225,7 @@ testVirHostdevReAttachPCIHostdevs_unmanaged(void)
size_t active_count, inactive_count, i;
for (i = 0; i < nhostdevs; i++) {
- if (hostdevs[i]->managed != false) {
+ if (hostdevs[i]->managed != VIR_PCI_MANAGED_NO) {
VIR_DEBUG("invalid test");
return -1;
}
@@ -259,7 +259,7 @@ testVirHostdevPreparePCIHostdevs_managed(void)
size_t active_count, inactive_count, i;
for (i = 0; i < nhostdevs; i++)
- hostdevs[i]->managed = true;
+ hostdevs[i]->managed = VIR_PCI_MANAGED_YES;
active_count = virPCIDeviceListCount(mgr->activePCIHostdevs);
inactive_count = virPCIDeviceListCount(mgr->inactivePCIHostdevs);
@@ -310,7 +310,7 @@ testVirHostdevReAttachPCIHostdevs_managed(void)
size_t active_count, inactive_count, i;
for (i = 0; i < nhostdevs; i++) {
- if (hostdevs[i]->managed != true) {
+ if (hostdevs[i]->managed != VIR_PCI_MANAGED_YES) {
VIR_DEBUG("invalid test");
return -1;
}
--
2.5.0
8 years, 9 months
[libvirt] [ 0/3] more useful network ethernet type devices
by Vasiliy Tolstov
By default libvirt does not manages ethernet devices, bypass all control to qemu.
This series enable creating tap devices via libvirt, assign mac, ip address and routes.
Also when use specif linkstate down in xml, phisicaly down tap device.
This is very useful in case of using bird, quagga or somethink like this to forward
traffic to vm.
Main question about peer address assign. How to deal with absent peer address?
Now i'm simplify check that peer address is valid ip address, but may be this is wrong.
Vasiliy Tolstov (3):
autocreate tap device for ethernet network type
allow to specify peer to ip element in domain network
assign peer address if it provided in network
docs/schemas/interface.rng | 6 ++
include/libvirt/libvirt-domain.h | 1 +
src/conf/domain_conf.c | 14 +++-
src/conf/domain_conf.h | 1 +
src/conf/network_conf.c | 26 ++++++-
src/conf/network_conf.h | 1 +
src/lxc/lxc_container.c | 2 +-
src/network/bridge_driver.c | 2 +-
src/qemu/qemu_command.c | 38 +++++-----
src/qemu/qemu_hotplug.c | 36 +++++++--
src/qemu/qemu_interface.c | 158 +++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_interface.h | 5 ++
src/qemu/qemu_process.c | 6 ++
src/util/virnetdev.c | 43 +++++++----
src/util/virnetdev.h | 1 +
15 files changed, 300 insertions(+), 40 deletions(-)
--
2.7.3
8 years, 9 months