[libvirt] [PATCHv2 0/2] storage: Don't wipe volumes on remote filesystems with local tools
by Peter Krempa
Version 2 now splits the stuff into separate driver backend funcs.
Peter Krempa (2):
storage: wipe: Move helper code into storage backend
storage: Split out volume wiping as separate backend function
src/storage/storage_backend.c | 203 +++++++++++++++++++++++++++++++++
src/storage/storage_backend.h | 12 ++
src/storage/storage_backend_disk.c | 1 +
src/storage/storage_backend_fs.c | 3 +
src/storage/storage_backend_iscsi.c | 1 +
src/storage/storage_backend_logical.c | 1 +
src/storage/storage_backend_mpath.c | 1 +
src/storage/storage_backend_scsi.c | 1 +
src/storage/storage_driver.c | 205 +---------------------------------
9 files changed, 229 insertions(+), 199 deletions(-)
--
2.0.0
10 years, 4 months
[libvirt] [PATCH] esx: Fix a bug in the XML code for storage pools
by Geoff Hickey
For ESX, the code that builds XML descriptions for attached storage pools was
not setting the host count to anything when it returned a host name.
---
src/esx/esx_storage_backend_vmfs.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/esx/esx_storage_backend_vmfs.c b/src/esx/esx_storage_backend_vmfs.c
index 6bed3ce..cf0da84 100644
--- a/src/esx/esx_storage_backend_vmfs.c
+++ b/src/esx/esx_storage_backend_vmfs.c
@@ -488,6 +488,7 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags)
if (VIR_ALLOC_N(def.source.hosts, 1) < 0)
goto cleanup;
def.type = VIR_STORAGE_POOL_NETFS;
+ def.source.nhost = 1;
def.source.hosts[0].name = nasInfo->nas->remoteHost;
def.source.dir = nasInfo->nas->remotePath;
--
1.9.1
10 years, 4 months
[libvirt] [PATCH v2] support for QEMU vhost-user
by Michele Paolino
This patch adds support for the QEMU vhost-user feature to libvirt.
vhost-user enables the communication between a QEMU virtual machine
and other userspace process using the Virtio transport protocol.
It uses a char dev (e.g. Unix socket) for the control plane,
while the data plane based on shared memory.
The XML looks like:
<interface type='vhostuser'>
<source type='unix' path='/tmp/vhost.sock' mode='server'/>
<mac address='52:54:00:3b:83:1a'/>
<model type='virtio'/>
</interface>
changes from v1:
* addressed comments
* removed unnecessary checks
* series merged in a single patch
The previous version of this patch can be found at:
http://www.redhat.com/archives/libvir-list/2014-July/msg00111.html
Signed-off-by: Michele Paolino <m.paolino(a)virtualopensystems.com>
---
docs/formatdomain.html.in | 34 +++++++++
docs/schemas/domaincommon.rng | 25 +++++++
src/conf/domain_conf.c | 87 ++++++++++++++++++++++
src/conf/domain_conf.h | 10 ++-
src/libxl/libxl_conf.c | 1 +
src/lxc/lxc_process.c | 1 +
src/qemu/qemu_command.c | 63 ++++++++++++++++
src/uml/uml_conf.c | 5 ++
src/xenxs/xen_sxpr.c | 1 +
.../qemuxml2argv-net-vhostuser.args | 7 ++
.../qemuxml2argv-net-vhostuser.xml | 33 ++++++++
tests/qemuxml2argvtest.c | 1 +
tests/qemuxml2xmltest.c | 1 +
13 files changed, 267 insertions(+), 2 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 3f8bbee..606b7d4 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -3927,6 +3927,40 @@ qemu-kvm -net nic,model=? /dev/null
<span class="since">Since 0.9.5</span>
</p>
+ <h5><a name="elementVhostuser">vhost-user interface</a></h5>
+
+ <p>
+ vhost-user enables the communication between a QEMU virtual machine
+ and other userspace process using the Virtio transport protocol.
+ A char dev (e.g. Unix socket) is used for the control plane, while
+ the data plane is based on shared memory.
+ </p>
+
+<pre>
+ ...
+ <devices>
+ <interface type='vhostuser'>
+ <source type='unix' path='/tmp/vhost.sock' mode='server'>
+ </source>
+ <mac address='52:54:00:3b:83:1a'>
+ </mac>
+ <model type='virtio'>
+ </model>
+ </interface>
+ </devices>
+ ...</pre>
+
+ <p>
+ The <code><source></code> element has to be specified
+ along with the type of char device.
+ Currently, only type='unix' is supported, where the path (the
+ directory path of the socket) and mode attributes are required.
+ Both <code>mode='server'</code> and <code>mode='client'</code>
+ are supported.
+ vhost-user requires the virtio model type, thus the
+ <code><model></code> element is mandatory.
+ </p>
+
<h4><a name="elementsInput">Input devices</a></h4>
<p>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index af51eee..c9c02b6 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1968,6 +1968,31 @@
</group>
<group>
<attribute name="type">
+ <value>vhostuser</value>
+ </attribute>
+ <interleave>
+ <element name="source">
+ <attribute name="type">
+ <choice>
+ <value>unix</value>
+ </choice>
+ </attribute>
+ <attribute name="path">
+ <ref name="absFilePath"/>
+ </attribute>
+ <attribute name="mode">
+ <choice>
+ <value>server</value>
+ <value>client</value>
+ </choice>
+ </attribute>
+ <empty/>
+ </element>
+ <ref name="interface-options"/>
+ </interleave>
+ </group>
+ <group>
+ <attribute name="type">
<value>network</value>
</attribute>
<interleave>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 8df43b7..fb286c6 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -349,6 +349,7 @@ VIR_ENUM_IMPL(virDomainFSWrpolicy, VIR_DOMAIN_FS_WRPOLICY_LAST,
VIR_ENUM_IMPL(virDomainNet, VIR_DOMAIN_NET_TYPE_LAST,
"user",
"ethernet",
+ "vhostuser",
"server",
"client",
"mcast",
@@ -1361,6 +1362,10 @@ void virDomainNetDefFree(virDomainNetDefPtr def)
VIR_FREE(def->data.ethernet.ipaddr);
break;
+ case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
+ virDomainChrSourceDefFree(def->data.vhostuser);
+ break;
+
case VIR_DOMAIN_NET_TYPE_SERVER:
case VIR_DOMAIN_NET_TYPE_CLIENT:
case VIR_DOMAIN_NET_TYPE_MCAST:
@@ -6665,6 +6670,9 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
char *mode = NULL;
char *linkstate = NULL;
char *addrtype = NULL;
+ char *vhostuser_mode = NULL;
+ char *vhostuser_path = NULL;
+ char *vhostuser_type = NULL;
virNWFilterHashTablePtr filterparams = NULL;
virDomainActualNetDefPtr actual = NULL;
xmlNodePtr oldnode = ctxt->node;
@@ -6710,6 +6718,12 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
xmlStrEqual(cur->name, BAD_CAST "source")) {
dev = virXMLPropString(cur, "dev");
mode = virXMLPropString(cur, "mode");
+ } else if (!vhostuser_path && !vhostuser_mode && !vhostuser_type
+ && def->type == VIR_DOMAIN_NET_TYPE_VHOSTUSER &&
+ xmlStrEqual(cur->name, BAD_CAST "source")) {
+ vhostuser_type = virXMLPropString(cur, "type");
+ vhostuser_path = virXMLPropString(cur, "path");
+ vhostuser_mode = virXMLPropString(cur, "mode");
} else if (!def->virtPortProfile
&& xmlStrEqual(cur->name, BAD_CAST "virtualport")) {
if (def->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
@@ -6867,6 +6881,65 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
actual = NULL;
break;
+ case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
+ if (STRNEQ_NULLABLE(model, "virtio")) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Wrong or no <model> 'type' attribute "
+ "specified with <interface type='vhostuser'/>. "
+ "vhostuser requires the virtio-net* frontend"));
+ goto error;
+ }
+
+ if (STRNEQ_NULLABLE(vhostuser_type, "unix")) {
+ if (vhostuser_type)
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Type='%s' unsupported for"
+ " <interface type='vhostuser'>"),
+ vhostuser_type);
+ else
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("No <source> 'type' attribute "
+ "specified for <interface "
+ "type='vhostuser'>"));
+ goto error;
+ }
+
+ if (vhostuser_path == NULL) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("No <source> 'path' attribute "
+ "specified with <interface "
+ "type='vhostuser'/>"));
+ goto error;
+ }
+
+ if (vhostuser_mode == NULL) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("No <source> 'mode' attribute "
+ "specified with <interface "
+ "type='vhostuser'/>"));
+ goto error;
+ }
+
+ if (VIR_ALLOC(def->data.vhostuser) < 0)
+ goto error;
+
+ def->data.vhostuser->type = VIR_DOMAIN_CHR_TYPE_UNIX;
+ def->data.vhostuser->data.nix.path = vhostuser_path;
+
+ if (STREQ(vhostuser_mode, "server"))
+ def->data.vhostuser->data.nix.listen = true;
+ else if (STREQ(vhostuser_mode, "client"))
+ def->data.vhostuser->data.nix.listen = false;
+ else {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Wrong <source> 'mode' attribute "
+ "specified with <interface "
+ "type='vhostuser'/>"));
+ goto error;
+ }
+ vhostuser_path = NULL;
+ break;
+
case VIR_DOMAIN_NET_TYPE_ETHERNET:
if (dev != NULL) {
def->data.ethernet.dev = dev;
@@ -7112,6 +7185,9 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
VIR_FREE(portgroup);
VIR_FREE(address);
VIR_FREE(port);
+ VIR_FREE(vhostuser_type);
+ VIR_FREE(vhostuser_path);
+ VIR_FREE(vhostuser_mode);
VIR_FREE(ifname);
VIR_FREE(dev);
virDomainActualNetDefFree(actual);
@@ -15987,6 +16063,17 @@ virDomainNetDefFormat(virBufferPtr buf,
def->data.ethernet.ipaddr);
break;
+ case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
+ if (def->data.vhostuser->type == VIR_DOMAIN_CHR_TYPE_UNIX) {
+ virBufferAddLit(buf, "<source type='unix'");
+ virBufferEscapeString(buf, " path='%s'",
+ def->data.vhostuser->data.nix.path);
+ if (def->data.vhostuser->data.nix.listen)
+ virBufferAddLit(buf, " mode='server'");
+ virBufferAddLit(buf, "/>\n");
+ }
+ break;
+
case VIR_DOMAIN_NET_TYPE_BRIDGE:
virBufferEscapeString(buf, "<source bridge='%s'/>\n",
def->data.bridge.brname);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index eb5bad7..91f7524 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -133,6 +133,12 @@ typedef virDomainIdMapDef *virDomainIdMapDefPtr;
typedef struct _virDomainPanicDef virDomainPanicDef;
typedef virDomainPanicDef *virDomainPanicDefPtr;
+/* forward declarations virDomainChrSourceDef, required by
+ * virDomainNetDef
+ */
+typedef struct _virDomainChrSourceDef virDomainChrSourceDef;
+typedef virDomainChrSourceDef *virDomainChrSourceDefPtr;
+
/* Flags for the 'type' field in virDomainDeviceDef */
typedef enum {
VIR_DOMAIN_DEVICE_NONE = 0,
@@ -795,6 +801,7 @@ struct _virDomainFSDef {
typedef enum {
VIR_DOMAIN_NET_TYPE_USER,
VIR_DOMAIN_NET_TYPE_ETHERNET,
+ VIR_DOMAIN_NET_TYPE_VHOSTUSER,
VIR_DOMAIN_NET_TYPE_SERVER,
VIR_DOMAIN_NET_TYPE_CLIENT,
VIR_DOMAIN_NET_TYPE_MCAST,
@@ -880,6 +887,7 @@ struct _virDomainNetDef {
char *dev;
char *ipaddr;
} ethernet;
+ virDomainChrSourceDefPtr vhostuser;
struct {
char *address;
int port;
@@ -1006,8 +1014,6 @@ typedef enum {
} virDomainChrSpicevmcName;
/* The host side information for a character device. */
-typedef struct _virDomainChrSourceDef virDomainChrSourceDef;
-typedef virDomainChrSourceDef *virDomainChrSourceDefPtr;
struct _virDomainChrSourceDef {
int type; /* virDomainChrType */
union {
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 4b6b5c0..c196136 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -955,6 +955,7 @@ libxlMakeNic(virDomainDefPtr def,
return -1;
break;
}
+ case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
case VIR_DOMAIN_NET_TYPE_USER:
case VIR_DOMAIN_NET_TYPE_SERVER:
case VIR_DOMAIN_NET_TYPE_CLIENT:
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index 0aef13a..854f65d 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -437,6 +437,7 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn,
case VIR_DOMAIN_NET_TYPE_USER:
case VIR_DOMAIN_NET_TYPE_ETHERNET:
+ case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
case VIR_DOMAIN_NET_TYPE_SERVER:
case VIR_DOMAIN_NET_TYPE_CLIENT:
case VIR_DOMAIN_NET_TYPE_MCAST:
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index af4d009..e2d4645 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6923,6 +6923,66 @@ qemuBuildGraphicsCommandLine(virQEMUDriverConfigPtr cfg,
}
static int
+qemuBuildVhostuserCommandLine(virCommandPtr cmd,
+ virDomainDefPtr def,
+ virDomainNetDefPtr net,
+ virQEMUCapsPtr qemuCaps)
+{
+ virBuffer chardev_buf = VIR_BUFFER_INITIALIZER;
+ virBuffer netdev_buf = VIR_BUFFER_INITIALIZER;
+
+ char* nic = NULL;
+ char* str = NULL;
+
+ if (!qemuDomainSupportsNetdev(def, qemuCaps, net)) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("Netdev support unavailable"));
+ goto error;
+ }
+
+ if (net->data.vhostuser->type == VIR_DOMAIN_CHR_TYPE_UNIX) {
+ virBufferAsprintf(&chardev_buf, "socket,id=char%s,path=%s%s",
+ net->info.alias, net->data.vhostuser->data.nix.path,
+ net->data.vhostuser->data.nix.listen ? ",server" : "");
+ }
+
+ virBufferAsprintf(&netdev_buf, "type=vhost-user,id=host%s,chardev=char%s",
+ net->info.alias, net->info.alias);
+
+ if (virBufferError(&chardev_buf) || virBufferError(&netdev_buf)) {
+ virReportOOMError();
+ goto error;
+ }
+
+ str = virBufferContentAndReset(&chardev_buf);
+ virCommandAddArgList(cmd, "-chardev", str, NULL);
+ VIR_FREE(str);
+
+ str = virBufferContentAndReset(&netdev_buf);
+ virCommandAddArgList(cmd, "-netdev", str, NULL);
+ VIR_FREE(str);
+
+ if (!(nic = qemuBuildNicDevStr(def, net, -1, 0, 0, qemuCaps))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("Error generating NIC -device string"));
+ goto error;
+ }
+
+ virCommandAddArgList(cmd, "-device", nic, NULL);
+ VIR_FREE(nic);
+
+ return 0;
+
+ error:
+ virBufferFreeAndReset(&chardev_buf);
+ virBufferFreeAndReset(&netdev_buf);
+ VIR_FREE(nic);
+ VIR_FREE(str);
+
+ return -1;
+}
+
+static int
qemuBuildInterfaceCommandLine(virCommandPtr cmd,
virQEMUDriverPtr driver,
virConnectPtr conn,
@@ -6945,6 +7005,9 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
int actualType = virDomainNetGetActualType(net);
size_t i;
+ if (actualType == VIR_DOMAIN_NET_TYPE_VHOSTUSER)
+ return qemuBuildVhostuserCommandLine(cmd, def, net, qemuCaps);
+
if (actualType == VIR_DOMAIN_NET_TYPE_HOSTDEV) {
/* NET_TYPE_HOSTDEV devices are really hostdev devices, so
* their commandlines are constructed with other hostdevs.
diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c
index 464d56d..d33d9b4 100644
--- a/src/uml/uml_conf.c
+++ b/src/uml/uml_conf.c
@@ -182,6 +182,11 @@ umlBuildCommandLineNet(virConnectPtr conn,
}
break;
+ case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("vhostuser networking type not supported"));
+ goto error;
+
case VIR_DOMAIN_NET_TYPE_SERVER:
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("TCP server networking type not supported"));
diff --git a/src/xenxs/xen_sxpr.c b/src/xenxs/xen_sxpr.c
index aacf74c..fe49c42 100644
--- a/src/xenxs/xen_sxpr.c
+++ b/src/xenxs/xen_sxpr.c
@@ -1933,6 +1933,7 @@ xenFormatSxprNet(virConnectPtr conn,
virBufferEscapeSexpr(buf, "(ip '%s')", def->data.ethernet.ipaddr);
break;
+ case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
case VIR_DOMAIN_NET_TYPE_USER:
case VIR_DOMAIN_NET_TYPE_SERVER:
case VIR_DOMAIN_NET_TYPE_CLIENT:
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.args b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.args
new file mode 100644
index 0000000..cc66ec3
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.args
@@ -0,0 +1,7 @@
+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 1 -nographic -nodefaults -monitor unix:/tmp/test-monitor,server,nowait \
+-no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 \
+-chardev socket,id=charnet0,path=/tmp/vhost.sock,server \
+-netdev type=vhost-user,id=hostnet0,chardev=charnet0 \
+-device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:ee:96:6b,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.xml
new file mode 100644
index 0000000..b49d48e
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.xml
@@ -0,0 +1,33 @@
+<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'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'/>
+ <controller type='ide' index='0'/>
+ <controller type='pci' index='0' model='pci-root'/>
+ <interface type='vhostuser'>
+ <mac address='52:54:00:ee:96:6b'/>
+ <source type='unix' path='/tmp/vhost.sock' mode='server'/>
+ <model type='virtio'/>
+ </interface>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index d5066d2..2099624 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -927,6 +927,7 @@ mymain(void)
DO_TEST_FAILURE("misc-enable-s4", NONE);
DO_TEST("misc-no-reboot", NONE);
DO_TEST("misc-uuid", QEMU_CAPS_NAME, QEMU_CAPS_UUID);
+ DO_TEST("net-vhostuser", QEMU_CAPS_DEVICE, QEMU_CAPS_NETDEV);
DO_TEST("net-user", NONE);
DO_TEST("net-virtio", NONE);
DO_TEST("net-virtio-device",
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 200d50f..359125a 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -245,6 +245,7 @@ mymain(void)
DO_TEST("misc-disable-suspends");
DO_TEST("misc-enable-s4");
DO_TEST("misc-no-reboot");
+ DO_TEST("net-vhostuser");
DO_TEST("net-user");
DO_TEST("net-virtio");
DO_TEST("net-virtio-device");
--
1.9.3
10 years, 4 months
[libvirt] [PATCH 0/3] LXC guest network device name changes
by Cédric Bosdonnat
This patch series allows users to configure the network device name in the
LXC container. I intentionaly didn't allow this for hostdev net interfaces
as the NIC would be returned with a different name to the host and we have
no way to guess under what name it was returned to the host namespace.
This will help filling the feature gap with LXC WRT network configuration.
Cédric Bosdonnat (3):
lxc network configuration allows setting target container NIC name
lxc conf2xml: convert lxc.network.name for veth networks
lxc network device names change documentation
docs/formatdomain.html.in | 17 +++++++++++++
docs/schemas/domaincommon.rng | 17 +++++++++++++
src/conf/domain_conf.c | 27 ++++++++++++++++++++
src/conf/domain_conf.h | 2 ++
src/lxc/lxc_container.c | 29 +++++++++++++++++++---
src/lxc/lxc_native.c | 22 +++++++++++-----
src/lxc/lxc_process.c | 25 +++++++++++++++++++
.../lxcconf2xmldata/lxcconf2xml-physnetwork.config | 1 +
tests/lxcconf2xmldata/lxcconf2xml-simple.xml | 1 +
tests/lxcxml2xmldata/lxc-idmap.xml | 1 +
10 files changed, 132 insertions(+), 10 deletions(-)
--
1.8.4.5
10 years, 4 months
[libvirt] [PATCH 0/8] Add support for setting DAC permissions on remote filesystems
by Peter Krempa
Peter Krempa (8):
storage: Implement storage driver helper to chown disk images
storage: Add witness for checking storage volume use in security
driver
security: DAC: Remove superfluous link resolution
security: DAC: Introduce callback to perform image chown
security: DAC: Plumb usage of chown callback
qemu: Implement DAC driver chown callback to co-operate with storage
drv
storage: Implement virStorageFileCreate for local and gluster files
qemu: snapshot: Use storage driver to pre-create snapshot file
src/qemu/qemu_driver.c | 66 ++++++++++++++++----
src/security/security_dac.c | 109 +++++++++++++++++++++++-----------
src/security/security_dac.h | 3 +
src/security/security_manager.c | 4 +-
src/security/security_manager.h | 19 +++++-
src/storage/storage_backend.h | 6 ++
src/storage/storage_backend_fs.c | 29 +++++++++
src/storage/storage_backend_gluster.c | 27 +++++++++
src/storage/storage_driver.c | 58 ++++++++++++++++++
src/storage/storage_driver.h | 3 +
10 files changed, 277 insertions(+), 47 deletions(-)
--
2.0.0
10 years, 4 months
[libvirt] [PATCHv3 0/2] virsh: Fix negative value parsing in vcpuinfo
by Peter Krempa
Jincheng Miao (1):
virsh: forbid negative vcpu argument to vcpupin
Peter Krempa (1):
virsh: Reject negative numbers in vshCommandOptUInt
tests/vcpupin | 29 ++++++++++++++++++++++++++++-
tools/virsh-domain.c | 35 ++++++++++++++++++-----------------
tools/virsh.c | 4 ++--
3 files changed, 48 insertions(+), 20 deletions(-)
--
1.9.3
10 years, 4 months
[libvirt] [PREPOST 01/17] src/xenxs:Introduce function
by David Kiarie
From: Kiarie Kahurani <davidkiarie4(a)gmail.com>
Introduce function xenParseXMGeneral(virConfPtr conf, ...);
This function parses the xm general options such as uuid and name
signed-off-by: David Kiarie <davidkiarie4(a)gmail.com>
---
src/xenxs/xen_xm.c | 65 +++++++++++++++++++++++++++++++-----------------------
1 file changed, 37 insertions(+), 28 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 25a042d..1953a85 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -253,44 +253,25 @@ xenXMConfigGetUUID(virConfPtr conf, const char *name, unsigned char *uuid)
* Turn a config record into a lump of XML describing the
* domain, suitable for later feeding for virDomainCreateXML
*/
-virDomainDefPtr
-xenParseXM(virConfPtr conf, int xendConfigVersion,
- virCapsPtr caps)
+static int xenParseXMGeneral(virConfPtr conf, virDomainDefPtr def,
+ virCapsPtr caps)
{
+
+ const char *defaultMachine;
const char *str;
int hvm = 0;
- int val;
- virConfValuePtr list;
- virDomainDefPtr def = NULL;
- virDomainDiskDefPtr disk = NULL;
- virDomainNetDefPtr net = NULL;
- virDomainGraphicsDefPtr graphics = NULL;
- virDomainHostdevDefPtr hostdev = NULL;
- size_t i;
- const char *defaultMachine;
- int vmlocaltime = 0;
- unsigned long count;
- char *script = NULL;
- char *listenAddr = NULL;
-
- if (VIR_ALLOC(def) < 0)
- return NULL;
-
- def->virtType = VIR_DOMAIN_VIRT_XEN;
- def->id = -1;
if (xenXMConfigCopyString(conf, "name", &def->name) < 0)
- goto cleanup;
+ return -1;
if (xenXMConfigGetUUID(conf, "uuid", def->uuid) < 0)
- goto cleanup;
-
+ return -1;
if ((xenXMConfigGetString(conf, "builder", &str, "linux") == 0) &&
STREQ(str, "hvm"))
hvm = 1;
if (VIR_STRDUP(def->os.type, hvm ? "hvm" : "xen") < 0)
- goto cleanup;
+ return -1;
def->os.arch =
virCapabilitiesDefaultGuestArch(caps,
@@ -300,7 +281,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("no supported architecture for os type '%s'"),
def->os.type);
- goto cleanup;
+ return -1;
}
defaultMachine = virCapabilitiesDefaultGuestMachine(caps,
@@ -309,9 +290,37 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
virDomainVirtTypeToString(def->virtType));
if (defaultMachine != NULL) {
if (VIR_STRDUP(def->os.machine, defaultMachine) < 0)
- goto cleanup;
+ return -1;
}
+ return 0;
+}
+virDomainDefPtr
+xenParseXM(virConfPtr conf, int xendConfigVersion,
+ virCapsPtr caps)
+{
+ const char *str;
+ int hvm = 0;
+ int val;
+ virConfValuePtr list;
+ virDomainDefPtr def = NULL;
+ virDomainDiskDefPtr disk = NULL;
+ virDomainNetDefPtr net = NULL;
+ virDomainGraphicsDefPtr graphics = NULL;
+ virDomainHostdevDefPtr hostdev = NULL;
+ size_t i;
+ int vmlocaltime = 0;
+ unsigned long count;
+ char *script = NULL;
+ char *listenAddr = NULL;
+
+ if (VIR_ALLOC(def) < 0)
+ return NULL;
+ def->virtType = VIR_DOMAIN_VIRT_XEN;
+ def->id = -1;
+ if (xenParseXMGeneral(conf, def, caps) < 0)
+ goto cleanup;
+ hvm = (STREQ(def->os.type, "hvm"));
if (hvm) {
const char *boot;
if (xenXMConfigCopyString(conf, "kernel", &def->os.loader) < 0)
--
1.8.4.5
10 years, 4 months
[libvirt] [PATCH] blockjob: wait for pivot to complete
by Eric Blake
https://bugzilla.redhat.com/show_bug.cgi?id=1119173 documents that
commit eaba79d was flawed in the implementation of the
VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC flag when it comes to completing
a blockcopy. Basically, the qemu pivot action is async (the QMP
command returns immediately, but the user must wait for the
BLOCK_JOB_COMPLETE event to know that all I/O related to the job
has finally been flushed), but the libvirt command was documented
as synchronous by default. As active block commit will also be
using this code, it is worth fixing now.
* src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Don't skip wait
loop after pivot.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Shown here with extra context, to hopefully aid the review.
src/qemu/qemu_driver.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ecccf6c..300e49e 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -14973,45 +14973,45 @@ qemuDomainBlockJobImpl(virDomainObjPtr vm,
if (!device)
goto endjob;
disk = vm->def->disks[idx];
if (mode == BLOCK_JOB_PULL && disk->mirror) {
virReportError(VIR_ERR_BLOCK_COPY_ACTIVE,
_("disk '%s' already in active block job"),
disk->dst);
goto endjob;
}
if (mode == BLOCK_JOB_ABORT &&
(flags & VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT) &&
!(async && disk->mirror)) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("pivot of disk '%s' requires an active copy job"),
disk->dst);
goto endjob;
}
if (disk->mirror && mode == BLOCK_JOB_ABORT &&
(flags & VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT)) {
ret = qemuDomainBlockPivot(conn, driver, vm, device, disk);
- goto endjob;
+ goto waitjob;
}
if (base &&
(virStorageFileParseChainIndex(disk->dst, base, &baseIndex) < 0 ||
!(baseSource = virStorageFileChainLookup(disk->src, disk->src,
base, baseIndex, NULL))))
goto endjob;
if (baseSource) {
if (qemuGetDriveSourceString(baseSource, NULL, &basePath) < 0)
goto endjob;
if (flags & VIR_DOMAIN_BLOCK_REBASE_RELATIVE) {
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_CHANGE_BACKING_FILE)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("this QEMU binary doesn't support relative "
"block pull/rebase"));
goto endjob;
}
if (virStorageFileGetRelativeBackingPath(disk->src->backingStore,
baseSource,
@@ -15030,44 +15030,45 @@ qemuDomainBlockJobImpl(virDomainObjPtr vm,
qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorBlockJob(priv->mon, device, basePath, backingPath,
bandwidth, info, mode, async);
qemuDomainObjExitMonitor(driver, vm);
if (ret < 0)
goto endjob;
/* Snoop block copy operations, so future cancel operations can
* avoid checking if pivot is safe. */
if (mode == BLOCK_JOB_INFO && ret == 1 && disk->mirror &&
info->cur == info->end && info->type == VIR_DOMAIN_BLOCK_JOB_TYPE_COPY)
disk->mirroring = true;
/* A successful block job cancelation stops any mirroring. */
if (mode == BLOCK_JOB_ABORT && disk->mirror) {
/* XXX We should also revoke security labels and disk lease on
* the mirror, and audit that fact, before dropping things. */
virStorageSourceFree(disk->mirror);
disk->mirror = NULL;
disk->mirroring = false;
}
+ waitjob:
/* With synchronous block cancel, we must synthesize an event, and
* we silently ignore the ABORT_ASYNC flag. With asynchronous
* block cancel, the event will come from qemu, but without the
* ABORT_ASYNC flag, we must block to guarantee synchronous
* operation. We do the waiting while still holding the VM job,
* to prevent newly scheduled block jobs from confusing us. */
if (mode == BLOCK_JOB_ABORT) {
if (!async) {
/* Older qemu that lacked async reporting also lacked
* active commit, so we can hardcode the event to pull.
* We have to generate two variants of the event. */
int type = VIR_DOMAIN_BLOCK_JOB_TYPE_PULL;
int status = VIR_DOMAIN_BLOCK_JOB_CANCELED;
event = virDomainEventBlockJobNewFromObj(vm, disk->src->path, type,
status);
event2 = virDomainEventBlockJob2NewFromObj(vm, disk->dst, type,
status);
} else if (!(flags & VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC)) {
while (1) {
/* Poll every 50ms */
static struct timespec ts = { .tv_sec = 0,
.tv_nsec = 50 * 1000 * 1000ull };
--
1.9.3
10 years, 4 months
[libvirt] [PATCH v2] util: forbid freeing const pointers
by Eric Blake
Now that we've finally fixed all the violators, it's time to
enforce that any pointer to a const object is never freed (it
is aliasing some other memory, where the non-const original
should be freed instead). Alas, the code still needs a normal
vs. Coverity version, but at least we are still guaranteeing
that the macro call evaluates its argument exactly once.
I verified that we still get the following compiler warnings,
which in turn halts the build thanks to -Werror on gcc (hmm,
gcc 4.8.3's placement of the ^ for ?: type mismatch is a bit
off, but that's not our problem):
int oops1 = 0;
VIR_FREE(oops1);
const char *oops2 = NULL;
VIR_FREE(oops2);
struct blah { int dummy; } oops3;
VIR_FREE(oops3);
util/virauthconfig.c:159:35: error: pointer/integer type mismatch in conditional expression [-Werror]
VIR_FREE(oops1);
^
util/virauthconfig.c:161:5: error: passing argument 1 of 'virFree' discards 'const' qualifier from pointer target type [-Werror]
VIR_FREE(oops2);
^
In file included from util/virauthconfig.c:28:0:
util/viralloc.h:79:6: note: expected 'void *' but argument is of type 'const void *'
void virFree(void *ptrptr) ATTRIBUTE_NONNULL(1);
^
util/virauthconfig.c:163:35: error: type mismatch in conditional expression
VIR_FREE(oops3);
^
* src/util/viralloc.h (VIR_FREE): No longer cast away const.
* src/xenapi/xenapi_utils.c (xenSessionFree): Work around bogus
header.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
v2: this depends on the existing 1/4, while being a replacement
to all of 2-4/4 at once.
https://www.redhat.com/archives/libvir-list/2014-July/msg00716.html
src/util/viralloc.h | 11 +++++------
src/xenapi/xenapi_utils.c | 4 +++-
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/util/viralloc.h b/src/util/viralloc.h
index 7125e67..bf85c16 100644
--- a/src/util/viralloc.h
+++ b/src/util/viralloc.h
@@ -548,18 +548,17 @@ void virFree(void *ptrptr) ATTRIBUTE_NONNULL(1);
* This macro is safe to use on arguments with side effects.
*/
# if !STATIC_ANALYSIS
-/* The ternary ensures that ptr is a pointer and not an integer type,
- * while evaluating ptr only once. This gives us extra compiler
- * safety when compiling under gcc. For now, we intentionally cast
- * away const, since a number of callers safely pass const char *.
+/* The ternary ensures that ptr is a non-const pointer and not an
+ * integer type, all while evaluating ptr only once. This gives us
+ * extra compiler safety when compiling under gcc.
*/
-# define VIR_FREE(ptr) virFree((void *) (1 ? (const void *) &(ptr) : (ptr)))
+# define VIR_FREE(ptr) virFree(1 ? (void *) &(ptr) : (ptr))
# else
/* The Coverity static analyzer considers the else path of the "?:" and
* flags the VIR_FREE() of the address of the address of memory as a
* RESOURCE_LEAK resulting in numerous false positives (eg, VIR_FREE(&ptr))
*/
-# define VIR_FREE(ptr) virFree((void *) &(ptr))
+# define VIR_FREE(ptr) virFree(&(ptr))
# endif
void virAllocTestInit(void);
diff --git a/src/xenapi/xenapi_utils.c b/src/xenapi/xenapi_utils.c
index a80d136..ef89f42 100644
--- a/src/xenapi/xenapi_utils.c
+++ b/src/xenapi/xenapi_utils.c
@@ -44,13 +44,15 @@ void
xenSessionFree(xen_session *session)
{
size_t i;
+ char *tmp;
if (session->error_description != NULL) {
for (i = 0; i < session->error_description_count; i++)
VIR_FREE(session->error_description[i]);
VIR_FREE(session->error_description);
}
/* The session_id member is type of 'const char *'. Sigh. */
- VIR_FREE(session->session_id);
+ tmp = (char *)session->session_id;
+ VIR_FREE(tmp);
VIR_FREE(session);
}
--
1.9.3
10 years, 4 months