[libvirt] [PATCH 00/27] network: refactor to decouple virt drivers from network driver
by Daniel P. Berrangé
Currently the network driver registers a set of callbacks with the virt
driver in order to handle allocating/releasing network ports associated
with guest NICs.
This series introduces a virNetworkPortPtr object and associated XML
that describes a network port. The virt drivers now call public APIs
associated with this new object to create/delete ports for guest NICs.
There are some parts that are not yet addressed by this series
- The live updating of bandwidth limits on network ports
- The old code would re-connect VIFs to bridges, and/or change
bridges during startup. This code is deleted right now as it
doesn't belong in the network driver. It needs to move to the
virt drivers in some (to be determined) manner.
Daniel P. Berrangé (27):
conf: make virPCIDeviceAddressFormat void
network: restrict usage of port management APIs
network: pass a virNetworkPtr to port management APIs
conf: simplify link from hostdev back to network device
network: add missing bandwidth limits for bridge forward type
network: use 'bridge' as actual type instead of 'network'
virt drivers: don't handle type=network after resolving actual network
type
network: unconditionally merge port profiles
conf: introduce virNetworkPortDefPtr struct and XML support
network: stop passing virDomainNetDefPtr into bandwidth functions
network: make networkLogAllocation independent of domain conf
util: add API for copying virtual port profile data
conf: add APIs to convert virDomainNetDef to virNetworkPortDef
network: convert networkAllocateActualDevice to virNetworkPortDef
network: convert networkNotifyActualDevice to virNetworkPortDef
network: convert networkReleaseActualDevice to virNetworkPortDef
network: convert hook script to take a network port XML
network: introduce networkAllocatePort
network: introduce networkNotifyPort
network: introduce networkReleasePort
network: add public APIs for network port object
access: add permissions for network port objects
remote: add support for new network port APIs
virsh: add support for network port APIs
conf: support recording ports against virNetworkObjPtr
network: add implementation of network port APIs
conf: switch over to use network port APIs for virt drivers
include/libvirt/libvirt-network.h | 49 +
include/libvirt/virterror.h | 3 +
src/access/genpolkit.pl | 2 +-
src/access/viraccessdriver.h | 6 +
src/access/viraccessdrivernop.c | 11 +
src/access/viraccessdriverpolkit.c | 26 +
src/access/viraccessdriverstack.c | 25 +
src/access/viraccessmanager.c | 16 +
src/access/viraccessmanager.h | 6 +
src/access/viraccessperm.c | 8 +-
src/access/viraccessperm.h | 38 +
src/conf/Makefile.inc.am | 2 +
src/conf/device_conf.c | 3 +-
src/conf/device_conf.h | 6 +-
src/conf/domain_conf.c | 413 ++++++-
src/conf/domain_conf.h | 46 +-
src/conf/network_conf.c | 7 +-
src/conf/storage_adapter_conf.c | 4 +-
src/conf/virnetworkobj.c | 303 +++++
src/conf/virnetworkobj.h | 30 +
src/conf/virnetworkportdef.c | 497 ++++++++
src/conf/virnetworkportdef.h | 112 ++
src/datatypes.c | 60 +
src/datatypes.h | 41 +
src/driver-network.h | 27 +
src/libvirt-network.c | 351 ++++++
src/libvirt_private.syms | 21 +
src/libvirt_public.syms | 14 +
src/libxl/libxl_conf.c | 21 +-
src/libxl/libxl_domain.c | 28 +-
src/libxl/libxl_driver.c | 27 +-
src/lxc/lxc_driver.c | 37 +-
src/lxc/lxc_process.c | 21 +-
src/network/bridge_driver.c | 1069 +++++++++--------
src/qemu/qemu_command.c | 11 +-
src/qemu/qemu_domain_address.c | 4 +-
src/qemu/qemu_driver.c | 2 +-
src/qemu/qemu_hotplug.c | 84 +-
src/qemu/qemu_hotplug.h | 2 +-
src/qemu/qemu_interface.c | 12 +-
src/qemu/qemu_process.c | 32 +-
src/remote/remote_daemon_dispatch.c | 25 +
src/remote/remote_driver.c | 28 +
src/remote/remote_protocol.x | 89 +-
src/remote_protocol-structs | 47 +
src/rpc/gendispatch.pl | 18 +-
src/util/virerror.c | 9 +
src/util/virhook.c | 4 +-
src/util/virhook.h | 4 +-
src/util/virhostdev.c | 17 +-
src/util/virnetdevvportprofile.c | 16 +
src/util/virnetdevvportprofile.h | 2 +
tests/Makefile.am | 7 +
.../plug-bridge-mactbl.xml | 9 +
.../virnetworkportxml2xmldata/plug-bridge.xml | 9 +
.../virnetworkportxml2xmldata/plug-direct.xml | 12 +
.../plug-hostdev-pci.xml | 12 +
tests/virnetworkportxml2xmldata/plug-none.xml | 8 +
tests/virnetworkportxml2xmltest.c | 104 ++
tools/virsh-completer.c | 51 +
tools/virsh-completer.h | 4 +
tools/virsh-network.c | 399 +++++-
tools/virsh-network.h | 5 +
63 files changed, 3681 insertions(+), 675 deletions(-)
create mode 100644 src/conf/virnetworkportdef.c
create mode 100644 src/conf/virnetworkportdef.h
create mode 100644 tests/virnetworkportxml2xmldata/plug-bridge-mactbl.xml
create mode 100644 tests/virnetworkportxml2xmldata/plug-bridge.xml
create mode 100644 tests/virnetworkportxml2xmldata/plug-direct.xml
create mode 100644 tests/virnetworkportxml2xmldata/plug-hostdev-pci.xml
create mode 100644 tests/virnetworkportxml2xmldata/plug-none.xml
create mode 100644 tests/virnetworkportxml2xmltest.c
--
2.19.2
5 years, 9 months
[libvirt] [PATCH v2 0/4] Restructure firewall rules for virtual networks into private chains
by Daniel P. Berrangé
v1: https://www.redhat.com/archives/libvir-list/2018-November/msg00018.html
The virtual networks in NAT mode are supposed to only allow outbound
network access for guests. Unfortunately due to ordering of the firewall
rules libvirt creates, when you have multiple virtual networks, guests
on the more recently created virtual networks can connect to guests on
old virtual networks.
This was reported way back in 2008 but we always thought the fix would
be very complicated to deal with, so we've been putting it off forever.
In parallel with this there's also been a long standing desire since
2009 to move our firewall rules out of the builtin chains, to libvirt
private chains. This is to make it easier for admins to use hook scripts
to setup rules in the builtin chains that take priority over rules
libvirt creates.
In implementing the changes to use private chains, I suddenly realized
that fixing the network to network traffic blocking problem was trivial
if I grouped the forwarding rules into three distinct sets.
So this series finally fixes an annoying 10 year old bug, and implements
a 9 year old RFE.
It may take us a while, but we'll get to your bugs eventually ;-)
Changed in v2:
- Detect whether chains already exist before creating them
- Only try to delete legacy rules from builtin chain during startup
Daniel P. Berrangé (4):
network: add platform driver callbacks around firewall reload
util: pass layer into firewall query callback
util: create private chains for virtual network firewall rules
util: move virtual network firwall rules into private chains
src/libvirt_private.syms | 2 +
src/network/bridge_driver.c | 13 +-
src/network/bridge_driver_linux.c | 32 +++
src/network/bridge_driver_nop.c | 11 +
src/network/bridge_driver_platform.h | 3 +
src/nwfilter/nwfilter_ebiptables_driver.c | 17 +-
src/util/virfirewall.c | 2 +-
src/util/virfirewall.h | 1 +
src/util/viriptables.c | 254 +++++++++++++++---
src/util/viriptables.h | 4 +
.../nat-default-linux.args | 32 +--
.../nat-ipv6-linux.args | 48 ++--
.../nat-many-ips-linux.args | 60 ++---
.../nat-no-dhcp-linux.args | 46 ++--
.../nat-tftp-linux.args | 34 +--
.../route-default-linux.args | 22 +-
tests/virfirewalltest.c | 3 +-
17 files changed, 405 insertions(+), 179 deletions(-)
--
2.19.2
5 years, 10 months
[libvirt] [PATCH] qemu-options: Remove deprecated "-virtioconsole" option
by Thomas Huth
It's been deprecated since QEMU 3.0, and nobody complained so far, so
it is time to remove this option now.
Signed-off-by: Thomas Huth <thuth(a)redhat.com>
---
docs/qdev-device-use.txt | 4 ----
include/hw/boards.h | 1 -
qemu-deprecated.texi | 5 ----
qemu-options.hx | 10 --------
vl.c | 61 +-----------------------------------------------
5 files changed, 1 insertion(+), 80 deletions(-)
diff --git a/docs/qdev-device-use.txt b/docs/qdev-device-use.txt
index 98229b3..cc53e97 100644
--- a/docs/qdev-device-use.txt
+++ b/docs/qdev-device-use.txt
@@ -190,10 +190,6 @@ The appropriate DEVNAME depends on the machine type. For type "pc":
-device usb-braille,chardev=braille -chardev braille,id=braille
-* -virtioconsole becomes
- -device virtio-serial-pci,class=C,vectors=V,ioeventfd=IOEVENTFD,max_ports=N
- -device virtconsole,is_console=NUM,nr=NR,name=NAME
-
LEGACY-CHARDEV translates to -chardev HOST-OPTS... as follows:
* null becomes -chardev null
diff --git a/include/hw/boards.h b/include/hw/boards.h
index f82f284..5df67d2 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -181,7 +181,6 @@ struct MachineClass {
int default_cpus;
unsigned int no_serial:1,
no_parallel:1,
- use_virtcon:1,
no_floppy:1,
no_cdrom:1,
no_sdcard:1,
diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi
index 72b8191..5cc18b4 100644
--- a/qemu-deprecated.texi
+++ b/qemu-deprecated.texi
@@ -60,11 +60,6 @@ The @code{--no-frame} argument works with SDL 1.2 only. The other user
interfaces never implemented this in the first place. So this will be
removed together with SDL 1.2 support.
-@subsection -virtioconsole (since 3.0.0)
-
-Option @option{-virtioconsole} has been replaced by
-@option{-device virtconsole}.
-
@subsection -clock (since 3.0.0)
The @code{-clock} option is ignored since QEMU version 1.7.0. There is no
diff --git a/qemu-options.hx b/qemu-options.hx
index 269eda7..5330603 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -3635,16 +3635,6 @@ character to Control-t.
@end table
ETEXI
-DEF("virtioconsole", HAS_ARG, QEMU_OPTION_virtiocon, \
- "-virtioconsole c\n" \
- " set virtio console\n", QEMU_ARCH_ALL)
-STEXI
-@item -virtioconsole @var{c}
-@findex -virtioconsole
-Set virtio console.
-This option is deprecated, please use @option{-device virtconsole} instead.
-ETEXI
-
DEF("show-cursor", 0, QEMU_OPTION_show_cursor, \
"-show-cursor show cursor\n", QEMU_ARCH_ALL)
STEXI
diff --git a/vl.c b/vl.c
index a5ae5f2..595d610 100644
--- a/vl.c
+++ b/vl.c
@@ -164,7 +164,6 @@ int no_frame;
static int num_serial_hds;
static Chardev **serial_hds;
Chardev *parallel_hds[MAX_PARALLEL_PORTS];
-Chardev *virtcon_hds[MAX_VIRTIO_CONSOLES];
int win2k_install_hack = 0;
int singlestep = 0;
int smp_cpus;
@@ -215,7 +214,6 @@ bool xen_domid_restrict;
static int has_defaults = 1;
static int default_serial = 1;
static int default_parallel = 1;
-static int default_virtcon = 1;
static int default_monitor = 1;
static int default_floppy = 1;
static int default_cdrom = 1;
@@ -236,8 +234,6 @@ static struct {
{ .driver = "ide-drive", .flag = &default_cdrom },
{ .driver = "scsi-cd", .flag = &default_cdrom },
{ .driver = "scsi-hd", .flag = &default_cdrom },
- { .driver = "virtio-serial-pci", .flag = &default_virtcon },
- { .driver = "virtio-serial", .flag = &default_virtcon },
{ .driver = "VGA", .flag = &default_vga },
{ .driver = "isa-vga", .flag = &default_vga },
{ .driver = "cirrus-vga", .flag = &default_vga },
@@ -2374,7 +2370,6 @@ struct device_config {
DEV_BT, /* -bt */
DEV_SERIAL, /* -serial */
DEV_PARALLEL, /* -parallel */
- DEV_VIRTCON, /* -virtioconsole */
DEV_DEBUGCON, /* -debugcon */
DEV_GDB, /* -gdb, -s */
DEV_SCLP, /* s390 sclp */
@@ -2472,39 +2467,6 @@ static int parallel_parse(const char *devname)
return 0;
}
-static int virtcon_parse(const char *devname)
-{
- QemuOptsList *device = qemu_find_opts("device");
- static int index = 0;
- char label[32];
- QemuOpts *bus_opts, *dev_opts;
-
- if (strcmp(devname, "none") == 0)
- return 0;
- if (index == MAX_VIRTIO_CONSOLES) {
- error_report("too many virtio consoles");
- exit(1);
- }
-
- bus_opts = qemu_opts_create(device, NULL, 0, &error_abort);
- qemu_opt_set(bus_opts, "driver", "virtio-serial", &error_abort);
-
- dev_opts = qemu_opts_create(device, NULL, 0, &error_abort);
- qemu_opt_set(dev_opts, "driver", "virtconsole", &error_abort);
-
- snprintf(label, sizeof(label), "virtcon%d", index);
- virtcon_hds[index] = qemu_chr_new_mux_mon(label, devname);
- if (!virtcon_hds[index]) {
- error_report("could not connect virtio console"
- " to character backend '%s'", devname);
- return -1;
- }
- qemu_opt_set(dev_opts, "chardev", label, &error_abort);
-
- index++;
- return 0;
-}
-
static int debugcon_parse(const char *devname)
{
QemuOpts *opts;
@@ -3546,15 +3508,6 @@ int main(int argc, char **argv, char **envp)
exit(1);
}
break;
- case QEMU_OPTION_virtiocon:
- warn_report("This option is deprecated, "
- "use '-device virtconsole' instead");
- add_device_config(DEV_VIRTCON, optarg);
- default_virtcon = 0;
- if (strncmp(optarg, "mon:", 4) == 0) {
- default_monitor = 0;
- }
- break;
case QEMU_OPTION_parallel:
add_device_config(DEV_PARALLEL, optarg);
default_parallel = 0;
@@ -4171,9 +4124,6 @@ int main(int argc, char **argv, char **envp)
if (!has_defaults || machine_class->no_parallel) {
default_parallel = 0;
}
- if (!has_defaults || !machine_class->use_virtcon) {
- default_virtcon = 0;
- }
if (!has_defaults || machine_class->no_floppy) {
default_floppy = 0;
}
@@ -4206,8 +4156,7 @@ int main(int argc, char **argv, char **envp)
* usage, -nographic is just a no-op in this case.
*/
if (nographic
- && (default_parallel || default_serial
- || default_monitor || default_virtcon)) {
+ && (default_parallel || default_serial || default_monitor)) {
error_report("-nographic cannot be used with -daemonize");
exit(1);
}
@@ -4224,13 +4173,9 @@ int main(int argc, char **argv, char **envp)
add_device_config(DEV_PARALLEL, "null");
if (default_serial && default_monitor) {
add_device_config(DEV_SERIAL, "mon:stdio");
- } else if (default_virtcon && default_monitor) {
- add_device_config(DEV_VIRTCON, "mon:stdio");
} else {
if (default_serial)
add_device_config(DEV_SERIAL, "stdio");
- if (default_virtcon)
- add_device_config(DEV_VIRTCON, "stdio");
if (default_monitor)
monitor_parse("stdio", "readline", false);
}
@@ -4241,8 +4186,6 @@ int main(int argc, char **argv, char **envp)
add_device_config(DEV_PARALLEL, "vc:80Cx24C");
if (default_monitor)
monitor_parse("vc:80Cx24C", "readline", false);
- if (default_virtcon)
- add_device_config(DEV_VIRTCON, "vc:80Cx24C");
}
#if defined(CONFIG_VNC)
@@ -4473,8 +4416,6 @@ int main(int argc, char **argv, char **envp)
exit(1);
if (foreach_device_config(DEV_PARALLEL, parallel_parse) < 0)
exit(1);
- if (foreach_device_config(DEV_VIRTCON, virtcon_parse) < 0)
- exit(1);
if (foreach_device_config(DEV_DEBUGCON, debugcon_parse) < 0)
exit(1);
--
1.8.3.1
5 years, 10 months
[libvirt] [PATCH] storage: More uniquely identify NPIV LUNs
by John Ferlan
https://bugzilla.redhat.com/show_bug.cgi?id=1657468
Commit be1bb6c95 changed the way volumes were stored from a forward
linked list to a hash table. In doing so, it required that each vol
object would have 3 unique values as keys into tables - key, name,
and path. Due to how vHBA/NPIV LUNs are created/used this resulted
in a failure to utilize all the LUN's found during processing.
The virStorageBackendSCSINewLun uses virStorageBackendSCSISerial
in order to read/return the unique serial number of the LUN to be
used as a key for the volume.
However, for NPIV based LUNs the logic results in usage of the
same serial value for each path to the LUN. For example,
$ lsscsi -tg
...
[4:0:3:13] disk fc:0x207800c0ffd79b2a0xeb02ef /dev/sde /dev/sg16
[4:0:4:0] disk fc:0x50060169446021980xeb1f00 /dev/sdf /dev/sg17
[4:0:5:0] disk fc:0x50060161446021980xeb2000 /dev/sdg /dev/sg18
...
/lib/udev/scsi_id --replace-whitespace --whitelisted --device /dev/sde
3600c0ff000d7a2965c603e5401000000
/lib/udev/scsi_id --replace-whitespace --whitelisted --device /dev/sdf
350060160c460219850060160c4602198
/lib/udev/scsi_id --replace-whitespace --whitelisted --device /dev/sdg
350060160c460219850060160c4602198
The /dev/sdf and /dev/sdg although separate LUNs would end up with the
same serial number used for the vol->key value. When attempting to add
the LUN via virStoragePoolObjAddVol, the hash table code will indicate
that we have a duplicate:
virHashAddOrUpdateEntry:341 : internal error: Duplicate key
and thus the LUN is not added to the pool.
Digging deeper into the scsi_id output using the --export option one
will find that the only difference between the two luns is:
ID_TARGET_PORT=1 for /dev/sdf
ID_TARGET_PORT=2 for /dev/sdg
So, let's use the ID_TARGET_PORT string value along with the serial
to generate a more unique key using "@serial_PORT@target_port", where
@target_port is just the value of the ID_TARGET_PORT for the LUN.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/storage/storage_util.c | 61 +++++++++++++++++++++++++++++++++++++-
1 file changed, 60 insertions(+), 1 deletion(-)
diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
index a84ee5b600..d6d441c06d 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -3755,6 +3755,49 @@ virStorageBackendRefreshLocal(virStoragePoolObjPtr pool)
}
+static char *
+virStorageBackendSCSITargetPort(const char *dev)
+{
+ char *target_port = NULL;
+ const char *id;
+#ifdef WITH_UDEV
+ virCommandPtr cmd = virCommandNewArgList(
+ "/lib/udev/scsi_id",
+ "--replace-whitespace",
+ "--whitelisted",
+ "--export",
+ "--device", dev,
+ NULL
+ );
+
+ /* Run the program and capture its output */
+ virCommandSetOutputBuffer(cmd, &target_port);
+ if (virCommandRun(cmd, NULL) < 0)
+ goto cleanup;
+#endif
+
+ if (target_port && STRNEQ(target_port, "") &&
+ (id = strstr(target_port, "ID_TARGET_PORT="))) {
+ char *nl = strchr(id, '\n');
+ if (nl)
+ *nl = '\0';
+ id = strrchr(id, '=');
+ memmove(target_port, id + 1, strlen(id));
+ } else {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unable to uniquely identify target port for '%s'"),
+ dev);
+ }
+
+#ifdef WITH_UDEV
+ cleanup:
+ virCommandFree(cmd);
+#endif
+
+ return target_port;
+}
+
+
static char *
virStorageBackendSCSISerial(const char *dev)
{
@@ -3813,6 +3856,8 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr pool,
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
virStorageVolDefPtr vol = NULL;
char *devpath = NULL;
+ char *key = NULL;
+ char *target_port = NULL;
int retval = -1;
/* Check if the pool is using a stable target path. The call to
@@ -3877,9 +3922,21 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr pool,
VIR_STORAGE_VOL_READ_NOERROR)) < 0)
goto cleanup;
- if (!(vol->key = virStorageBackendSCSISerial(vol->target.path)))
+ if (!(key = virStorageBackendSCSISerial(vol->target.path)))
goto cleanup;
+ if (def->source.adapter.type == VIR_STORAGE_ADAPTER_TYPE_FC_HOST &&
+ STRNEQ(key, vol->target.path)) {
+ /* NPIV based LUNs use the same "serial" key. In order to distinguish
+ * we need to append a port value */
+ if (!(target_port = virStorageBackendSCSITargetPort(vol->target.path)))
+ goto cleanup;
+ if (virAsprintf(&vol->key, "%s_PORT%s", key, target_port) < 0)
+ goto cleanup;
+ } else {
+ VIR_STEAL_PTR(vol->key, key);
+ }
+
def->capacity += vol->target.capacity;
def->allocation += vol->target.allocation;
@@ -3892,6 +3949,8 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr pool,
cleanup:
virStorageVolDefFree(vol);
VIR_FREE(devpath);
+ VIR_FREE(target_port);
+ VIR_FREE(key);
return retval;
}
--
2.17.2
5 years, 10 months
[libvirt] [PATCH v2] qemu: Assign device address before qemuDomainSupportsNicdev
by Wang Yechao
qemuDomainSupportsNicdev will check the device address type on
aarch64. If it is invoked before device address assigned, hotadd
vhostuser interface with no address specified will get error.
Let qemuDomainEnsurePCIAddress run before qemuDomainSupportsNicdev.
Signed-off-by: Wang Yechao <wang.yechao255(a)zte.com.cn>
---
v1 patch:
https://www.redhat.com/archives/libvir-list/2018-December/msg00435.html
Changes in v2:
- do not modify the address type, let qemuDomainEnsurePCIAddress do it.
---
src/qemu/qemu_hotplug.c | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 8da0233..f25c8db 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1369,6 +1369,25 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
if (qemuAssignDeviceNetAlias(vm->def, net, -1) < 0)
goto cleanup;
+ if (qemuDomainIsS390CCW(vm->def) &&
+ net->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI &&
+ virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_CCW)) {
+ net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW;
+ if (!(ccwaddrs = virDomainCCWAddressSetCreateFromDomain(vm->def)))
+ goto cleanup;
+ if (virDomainCCWAddressAssign(&net->info, ccwaddrs,
+ !net->info.addr.ccw.assigned) < 0)
+ goto cleanup;
+ } else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("virtio-s390 net device cannot be hotplugged."));
+ goto cleanup;
+ } else if (qemuDomainEnsurePCIAddress(vm, &dev, driver) < 0) {
+ goto cleanup;
+ }
+
+ releaseaddr = true;
+
switch (actualType) {
case VIR_DOMAIN_NET_TYPE_BRIDGE:
case VIR_DOMAIN_NET_TYPE_NETWORK:
@@ -1503,25 +1522,6 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
goto cleanup;
}
- if (qemuDomainIsS390CCW(vm->def) &&
- net->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI &&
- virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_CCW)) {
- net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW;
- if (!(ccwaddrs = virDomainCCWAddressSetCreateFromDomain(vm->def)))
- goto cleanup;
- if (virDomainCCWAddressAssign(&net->info, ccwaddrs,
- !net->info.addr.ccw.assigned) < 0)
- goto cleanup;
- } else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("virtio-s390 net device cannot be hotplugged."));
- goto cleanup;
- } else if (qemuDomainEnsurePCIAddress(vm, &dev, driver) < 0) {
- goto cleanup;
- }
-
- releaseaddr = true;
-
if (VIR_ALLOC_N(tapfdName, tapfdSize) < 0 ||
VIR_ALLOC_N(vhostfdName, vhostfdSize) < 0)
goto cleanup;
--
1.8.3.1
5 years, 10 months
[libvirt] [PATCH RFC 00/51] refactor block job handling and add support for new event/commands (blockdev-add saga)
by Peter Krempa
This series refactors how libvirt stores block job data and handles
block job events in general. This is done in preparation for -blockdev
support where we'll need to add support for the 'blockdev-create' job
which is not associated to any frontend 'disk' in some cases.
This series introduces a new structure and table of blockjobs currently
running and implements handlers for the new even "JOB_STATUS_CHANGE".
RFC status excuses:
- the series needs much more testing than I did
- the last few patches are true RFC
- I didn't port/refactor the rest of the blockjob finishing code that
I have for the individual job types after the big refactor so there
aren't any examples for the -blockdev case yet.
I'll post the link to a repo containing the patches some time later.
Peter Krempa (51):
qemu: blockjob: Extract emitting of libvirt events
qemu: blockjob: Emit VIR_DOMAIN_EVENT_ID_BLOCK_JOB only for local
disks
qemu: processBlockJobEvent: Use qemuBlockJobUpdate to process block
job events
qemu: blockjob: Unexport qemuBlockJobEventProcess
qemu: blockjob: Rename public APIs
qemu: blockjob: Remove header dependency on qemu_domain.h
qemu: Consolidate disk blockjob variables into a structure
qemu: process: Consolidate error paths in qemuProcessHandleBlockJob
qemu: blockjob: Rename qemuBlockJobEventProcess to
qemuBlockJobEventProcessLegacy
qemu: blockjob: Split out handling of comlpleted jobs
qemu: migration: Properly note that non-shared-storage migration uses
a blockjob
qemu: process: refresh block jobs on reconnect
qemu: driver: Remove block job status reprobing from
qemuDomainBlockPivot
qemu: migration: Simplify cancellation of migration blockjobs
qemu: blockjob: Turn struct qemuBlockJobData into a virObject
qemu: blockjob: Clarify that job 'status' field contains new state
qemu: migration: Separate startup of disk mirror from migration logic
qemu: blockjob: Add functions for block job state control
qemu: blockjob: Drop unnecessary calls to qemuBlockJobSyncEndDisk
qemu: blockjob: Add reference to disk into struct qemuBlockJobData
qemu: blockjob: Record job type when starting the job
qemu: blockjob: Pass in job to qemuBlockJobEventProcessLegacy
qemu: blockjob: Convert qemuBlockJobSyncBeginDisk to work with the job
qemu: blockjob: Track current state of blockjob
qemu: migration: Extract reporting of disk migration error
qemu: blockjob: Remove error propagation from qemuBlockJobUpdateDisk
qemu: blockjob: Consume new block job state in the processing function
qemu: blockjob: Pass job into qemuBlockJobUpdateDisk and rename it
qemu: Allocate diskPriv->blockjob only when there's a blockjob
qemu: migration: Don't call qemuBlockJobSyncEndDisk when block job has
terminated
qemu: blockjob: Convert qemuBlockJobSyncEndDisk to take job instead of
disk
qemu: blockjob: Add job name into the data
qemu: domain: Add global table of blockjobs
qemu: blockjob: Register new and running blockjobs in the global table
qemu: blockjob: Add string convertors for blockjob type and state
enums
qemu: domain: Store blockjob data in the status XML
tests: qemustatusxml2xml: Add test case for block job tracking
qemu: monitor: Add new fields for 'block-stream' command
qemu: monitor: Add new fields for 'block-commit' command
qemu: monitor: Add new fields for 'blockdev-mirror' command
qemu: monitor: Add support for 'job-dismiss' command
qemu: monitor: Add support for 'job-cancel' command
qemu: monitor: Add support for 'job-complete' command
qemu: monitor: Add infrastructure for 'query-jobs'
qemu: blockjob: Add 'concluded' state for a block job
qemu: monitor: Implement support for 'JOB_STATUS_CHANGE' event
qemu: process: Don't trigger BLOCK_JOB* events with -blockdev
qemu: blockjob: Add helper to convert monitor job status to internal
state
qemu: Add handler for job state change event
qemu: blockjob: Add modern block job event handler
qemu: process: Refresh -blockdev based blockjobs on reconnect to qemu
src/qemu/qemu_blockjob.c | 687 ++++++++++++++----
src/qemu/qemu_blockjob.h | 111 ++-
src/qemu/qemu_domain.c | 123 +++-
src/qemu/qemu_domain.h | 13 +-
src/qemu/qemu_driver.c | 114 ++-
src/qemu/qemu_migration.c | 233 +++---
src/qemu/qemu_monitor.c | 120 ++-
src/qemu/qemu_monitor.h | 82 ++-
src/qemu/qemu_monitor_json.c | 239 +++++-
src/qemu/qemu_monitor_json.h | 28 +-
src/qemu/qemu_process.c | 179 ++++-
.../query-jobs-create.json | 20 +
.../query-jobs-create.result | 11 +
.../qemumonitorjsondata/query-jobs-empty.json | 1 +
.../query-jobs-empty.result | 0
tests/qemumonitorjsontest.c | 101 ++-
.../blockjob-blockdev-in.xml | 364 ++++++++++
.../blockjob-blockdev-out.xml | 1 +
tests/qemuxml2xmltest.c | 2 +
19 files changed, 2097 insertions(+), 332 deletions(-)
create mode 100644 tests/qemumonitorjsondata/query-jobs-create.json
create mode 100644 tests/qemumonitorjsondata/query-jobs-create.result
create mode 100644 tests/qemumonitorjsondata/query-jobs-empty.json
create mode 100644 tests/qemumonitorjsondata/query-jobs-empty.result
create mode 100644 tests/qemustatusxml2xmldata/blockjob-blockdev-in.xml
create mode 120000 tests/qemustatusxml2xmldata/blockjob-blockdev-out.xml
--
2.19.2
5 years, 10 months
[libvirt] [PATCH] qemu: Update a domain's persistent definition file if it's defined
by Wang Yechao
From: Li XueLei <li.xuelei1(a)zte.com.cn>
During making disk snapshot in an active domain, sometimes we
should update the domain's persistent definition.We must check if
the domain is defined, before we update the persistent definition
file.
First,we create a vm.Then,define the vm and undefine the vm.Last create a
--memspec snapshot for the vm.Now,we will find a persistent definition
file in the config directory if we don't use this patch.
Signed-off-by: Li XueLei <li.xuelei1(a)zte.com.cn>
---
src/qemu/qemu_driver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index e32257f..94dcb97 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -15330,7 +15330,7 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver,
if (ret == 0 || !do_transaction) {
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0 ||
- (persist && virDomainSaveConfig(cfg->configDir, driver->caps,
+ (vm->persistent && persist && virDomainSaveConfig(cfg->configDir, driver->caps,
vm->newDef) < 0))
ret = -1;
}
--
1.8.3.1
5 years, 10 months
[libvirt] [PATCH v5 00/36] BaselineHypervisorCPU using QEMU QMP exchanges
by Chris Venteicher
Some architectures (S390) depend on QEMU to compute baseline CPU model and
expand a models feature set.
Interacting with QEMU requires starting the QEMU process and completing one or
more query-cpu-model-baseline QMP exchanges with QEMU in addition to a
query-cpu-model-expansion QMP exchange to expand all features in the model.
See "s390x CPU models: exposing features" patch set on Qemu-devel for discussion
of QEMU aspects.
This is part of resolution of: https://bugzilla.redhat.com/show_bug.cgi?id=1511999
-----
This patch set fixes all process code issues identified here:
https://www.redhat.com/archives/libvir-list/2018-November/msg00349.html
in patches 1-22 of the series.
The remaining patches implement the BaselineHypervisorCPU changes using
the non-domain qemu process code.
The process changes (patches 1-22)...
- Make the process code generic (not capabilities specific) for use by
BaselineHypervisorCPU
- Many of the process patches are simple code moves with implementation
changes in other distinct patches
- A thread safe library function creates a unique directory under libDir for each QEMU
process (for QMP messaging) to decouple processes in terms of sockets and
file system footprint.
The BaselineHypervisorCPU changes (patches 22-36)...
- Fix all issues raised in patch sets 1-4.
Thanks,
Chris
Chris Venteicher (36):
qemu_process: Move process code from qemu_capabilities to qemu_process
qemu_process: Use qemuProcessQmp prefix
qemu_process: Limit qemuProcessQmpNew to const input strings
qemu_process: Refer to proc not cmd in process code
qemu_process: Use consistent name for stop process function
qemu_capabilities: Stop QEMU process before freeing
qemu_process: Use qemuProcessQmp struct for a single process
qemu_process: All ProcessQMP errors are fatal
qemu_process: Persist stderr in qemuProcessQmp struct
qemu_process: Introduce qemuProcessQmpStart
qemu_process: Collect monitor code in single function
qemu_process: Store libDir in qemuProcessQmp struct
qemu_process: Setup paths within qemuProcessQmpInit
qemu_process: Stop retaining Monitor config in qemuProcessQmp
qemu_process: Don't open monitor if process failed
qemu_process: Cleanup qemuProcessQmp alloc function
qemu_process: Cleanup qemuProcessQmpStop function
qemu_process: Catch process free before process stop
qemu_monitor: Make monitor callbacks optional
qemu_process: Enter QMP command mode when starting QEMU Process
qemu_process: Use unique directories for QMP processes
qemu_process: Stop locking QMP process monitor immediately
qemu_monitor: Introduce qemuMonitorCPUModelInfoNew
qemu_monitor: Introduce qemuMonitorCPUModelInfo / JSON conversion
qemu_capabilities: Introduce virQEMuCapsMigratablePropsDiff
qemu_monitor: qemuMonitorGetCPUModelExpansion inputs and outputs
CPUModelInfo
qemu_capabilities: Introduce CPUModelInfo to virCPUDef function
qemu_capabilities: Introduce virCPUDef to CPUModelInfo function
qemu_monitor: Support query-cpu-model-baseline QMP command
qemu_driver: Consolidate code to baseline using libvirt
qemu_driver: Decouple code for baseline using libvirt
qemu_driver: Identify using libvirt as a distinct way to compute
baseline
qemu_driver: Support baseline calculation using QEMU
qemu_driver: Support feature expansion via QEMU when baselining cpu
qemu_driver: Remove unsupported props in expanded hypervisor baseline
output
qemu_monitor: Default props to migratable when expanding cpu model
src/qemu/qemu_capabilities.c | 617 ++++++++----------
src/qemu/qemu_capabilities.h | 4 +
src/qemu/qemu_driver.c | 216 +++++-
src/qemu/qemu_monitor.c | 184 +++++-
src/qemu/qemu_monitor.h | 29 +-
src/qemu/qemu_monitor_json.c | 226 +++++--
src/qemu/qemu_monitor_json.h | 12 +-
src/qemu/qemu_process.c | 356 ++++++++++
src/qemu/qemu_process.h | 32 +
tests/cputest.c | 11 +-
.../caps_2.10.0.s390x.xml | 60 +-
.../caps_2.11.0.s390x.xml | 58 +-
.../caps_2.12.0.s390x.xml | 56 +-
.../qemucapabilitiesdata/caps_2.8.0.s390x.xml | 32 +-
.../qemucapabilitiesdata/caps_2.9.0.s390x.xml | 34 +-
.../qemucapabilitiesdata/caps_3.0.0.s390x.xml | 64 +-
tests/qemucapabilitiestest.c | 7 +
17 files changed, 1396 insertions(+), 602 deletions(-)
--
2.17.1
5 years, 10 months
[libvirt] [PATCH] util: Remove unnecessary ATTRIBUTE_NONNULL for virCommandAddArg[Pair]
by John Ferlan
Commit 912c6b22 modified the virCommandAddArg and virCommandAddArgPair
to perform NULL argument checking; however, no corresponding change
to the prototypes was made to remove the ATTRIBUTE_NONNULL, so the
Coverity build failed. Adjust the prototypes accordingly.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
It's a build breaker for Coverity or anything that enables STATIC_ANALYSIS
so I'll push under that rule.
src/util/vircommand.h | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/util/vircommand.h b/src/util/vircommand.h
index dbf5041890..100f7a06e0 100644
--- a/src/util/vircommand.h
+++ b/src/util/vircommand.h
@@ -123,7 +123,7 @@ void virCommandAddEnvPassAllowSUID(virCommandPtr cmd,
void virCommandAddEnvPassCommon(virCommandPtr cmd);
void virCommandAddArg(virCommandPtr cmd,
- const char *val) ATTRIBUTE_NONNULL(2);
+ const char *val);
void virCommandAddArgBuffer(virCommandPtr cmd,
virBufferPtr buf);
@@ -134,8 +134,7 @@ void virCommandAddArgFormat(virCommandPtr cmd,
void virCommandAddArgPair(virCommandPtr cmd,
const char *name,
- const char *val)
- ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
+ const char *val);
void virCommandAddArgSet(virCommandPtr cmd,
const char *const*vals) ATTRIBUTE_NONNULL(2);
--
2.17.2
5 years, 10 months
[libvirt] [PATCH 0/4] util: Fixing libvirt errors on cavium/thunder-nicvf
by Radoslaw Biernacki
ThunderX is Cavium SoC. This platform contain SRIOV NIC.
Unlike other commonly known network devices it does not have VF functionality
duplicated in its PF. PF is purely management device (on HW level).
This creates several problems with existing libvirt code as in many places
libvirt assumes that each VF netdev has PF netdev assigned.
This patch series trying to address issues which can be easily fixed.
(mostly bug fixes found while working on full featured solution)
First patch in series is most important as it allows to unblock the netdev
detection and use <hostdev> on this platform.
More details about those issues can be found at:
https://bugs.linaro.org/show_bug.cgi?id=3778
https://bugs.launchpad.net/charm-nova-compute/+bug/1771662
Radoslaw Biernacki (4):
util: fixing wrong assumption that PF has to have netdev assigned
util: Code simplification
util: Fix for NULL dereference
util: Fixing invalid error checking from virPCIGetNetname()
src/qemu/qemu_domain_address.c | 11 ++---
src/util/virhostdev.c | 2 +-
src/util/virnetdev.c | 50 ++++----------------
3 files changed, 16 insertions(+), 47 deletions(-)
--
2.14.1
5 years, 10 months