[libvirt] [PATCH 00/17] virsh bash completion improvements
by Lin Ma
Lin Ma (17):
virshDomainNameCompleter: Add some of VIR_CONNECT_LIST_DOMAINS_ flags
virsh: snapshot: Only return domains that have snapshot images
virsh: managedsave-*: Only return domains that have a managed save
image
virsh: checkpoint: Only return domains that have checkpoints
virsh: Add event completer to --enable/--disable args of perf command
vshReadlineParse: Ignore vshReadlineOptionsGenerator for VSH_OT_INT
options
virsh: Add network uuid completion to network-name command
virsh: Add domain uuid completion to domname command
virsh: Add iothread IDs completion to iothread* commands
virsh: Add completion for --iothread argument of attach-disk command
virsh: Add vcpu IDs completion to vcpupin command
virsh: Add vcpu list completion to setvcpu command
virsh: Add logical CPU list completion for --cpulist argument
virsh: limit completion of net-dhcp-leases to active networks
virsh: limit completion of net-port* to active networks
virsh: limit completion of backup-{begin, dumpxml} to active domains
virsh: limit completion of checkpoint-{create, delete} to active
domains
tools/virsh-backup.c | 4 +-
tools/virsh-checkpoint.c | 17 +-
tools/virsh-completer-domain.c | 264 +++++++++++++++++++++++++++++++-
tools/virsh-completer-domain.h | 31 ++++
tools/virsh-completer-network.c | 42 +++++
tools/virsh-completer-network.h | 4 +
tools/virsh-domain.c | 33 +++-
tools/virsh-network.c | 12 +-
tools/virsh-snapshot.c | 16 +-
tools/vsh.c | 1 +
10 files changed, 395 insertions(+), 29 deletions(-)
--
2.26.0
4 years, 2 months
[PATCH 00/17] qemu: Fix startup of VM with SCSI hostdev with long user-provided alias
by Peter Krempa
Device alias was used to generate the backend nodename. This doesn't
work well if somebody specifies a very long useralias since qemu limits
nodename to 32 bytes. Stop basing the nodename on the alias.
Peter Krempa (17):
virDomainHostdevSubsysSCSIiSCSIClear: Inline contents into only caller
virDomainStorageNetworkParseHosts: Switch to a more modern XML parsing
approach
virDomainHostdevSubsysSCSIHostDefParseXML: Switch to a more modern XML
parsing approach
syntax-check: Don't forbid curly braces around single line condition
body
qemuxml2argvtest: hostdev-scsi-virtio-scsi: Add hostdev with useralias
conf: Add virStorageSource member for SCSI host device config data
tests: qemustatusxml2xmldata: Rename 'disk-secinfo-upgrade' case to
'upgrade'
tests: qemustatusxml2xmldata: Add local SCSI hostdev to 'upgrade' case
qemu: domain: Fill in (i)SCSI backend nodename if it is not present in
status XML
qemuBuildHostdevSCSI(A|De)tachPrepare: Use virStorageSource in def for
SCSI hostdevs
qemuBlockStorageSourceAttachData: remove 'storageNodeNameCopy'
qemu: domain: Extract preparation of hostdev specific data to a
separate function
qemuDomainSecretHostdevPrepare: remove
qemuDomainPrepareHostdev: Allocate backend nodenames in the prepare
function
qemuDomainPrepareHostdev: base hostdev secret object names on backend
alias
qemuDomainPrepareHostdev: Don't base backend nodename on device alias
qemuxml2argvtest: hostdev-scsi-virtio-scsi: Use longer user-alias for
SCSI hostdev
build-aux/check-spacing.pl | 36 ----
docs/coding-style.rst | 8 +-
src/conf/domain_conf.c | 170 ++++++++---------
src/conf/domain_conf.h | 1 +
src/qemu/qemu_block.c | 1 -
src/qemu/qemu_block.h | 1 -
src/qemu/qemu_command.c | 74 +++++---
src/qemu/qemu_domain.c | 176 ++++++++++++------
src/qemu/qemu_domain.h | 8 +-
src/qemu/qemu_hotplug.c | 2 +-
src/qemu/qemu_process.c | 21 +++
tests/qemustatusxml2xmldata/modern-in.xml | 1 +
...-secinfo-upgrade-in.xml => upgrade-in.xml} | 9 +
...ecinfo-upgrade-out.xml => upgrade-out.xml} | 20 ++
.../hostdev-scsi-lsi.x86_64-latest.args | 38 ++--
...hostdev-scsi-virtio-scsi.x86_64-2.8.0.args | 5 +
...hostdev-scsi-virtio-scsi.x86_64-4.1.0.args | 5 +
...ostdev-scsi-virtio-scsi.x86_64-latest.args | 36 ++--
.../hostdev-scsi-virtio-scsi.xml | 8 +
.../hostdev-scsi-virtio-scsi.xml | 8 +
tests/qemuxml2xmltest.c | 2 +-
21 files changed, 370 insertions(+), 260 deletions(-)
rename tests/qemustatusxml2xmldata/{disk-secinfo-upgrade-in.xml => upgrade-in.xml} (98%)
rename tests/qemustatusxml2xmldata/{disk-secinfo-upgrade-out.xml => upgrade-out.xml} (96%)
--
2.26.2
4 years, 2 months
[PATCH 0/5] Support CSS and DASD devices in node_device driver
by Bjoern Walk
This series enables support for channel subsystem (CSS) devices,
Direct Access Storage Devices (DASDs) in the node_device driver and
adds support to create vfio-ccw mdev devices in the node_device driver.
Boris Fiuczynski (5):
node_device: refactor udevProcessCCW
node_device: detect CSS devices
virsh: nodedev: ability to filter CSS capabilities
node_device: detect DASD devices
node_device: mdev vfio-ccw support
docs/formatnode.html.in | 12 +++
docs/manpages/virsh.rst | 2 +-
docs/schemas/nodedev.rng | 16 ++++
include/libvirt/libvirt-nodedev.h | 1 +
src/conf/domain_addr.c | 2 +-
src/conf/domain_addr.h | 3 +
src/conf/node_device_conf.c | 5 ++
src/conf/node_device_conf.h | 4 +-
src/conf/virnodedeviceobj.c | 4 +-
src/libvirt-nodedev.c | 1 +
src/libvirt_private.syms | 1 +
src/node_device/node_device_driver.c | 49 +++++++++---
src/node_device/node_device_udev.c | 77 ++++++++++++++++---
.../ccw_0_0_10000-invalid.xml | 4 +-
tests/nodedevschemadata/ccw_0_0_ffff.xml | 4 +-
tests/nodedevschemadata/css_0_0_ffff.xml | 10 +++
tests/nodedevxml2xmltest.c | 1 +
tools/virsh-nodedev.c | 3 +
18 files changed, 172 insertions(+), 27 deletions(-)
create mode 100644 tests/nodedevschemadata/css_0_0_ffff.xml
--
2.24.1
4 years, 2 months
[libvirt PATCH v2] esx: improve some of the virErrorNumber used
by Pino Toscano
A lot of virReportError() calls use VIR_ERR_INTERNAL_ERROR to represent
the number of the error, even in cases where there is one fitting more.
Hence, replace some of them with better virErrorNumber values.
Signed-off-by: Pino Toscano <ptoscano(a)redhat.com>
---
Changes in v2:
- remove some of the VIR_ERR_INTERNAL_ERROR -> VIR_ERR_INVALID_ARG
changes as they refer to really internal bits
src/esx/esx_network_driver.c | 4 ++--
src/esx/esx_storage_backend_iscsi.c | 4 ++--
src/esx/esx_storage_backend_vmfs.c | 12 ++++++------
src/esx/esx_util.c | 2 +-
src/esx/esx_vi.c | 2 +-
5 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/src/esx/esx_network_driver.c b/src/esx/esx_network_driver.c
index d46fc9253d..88843aae2f 100644
--- a/src/esx/esx_network_driver.c
+++ b/src/esx/esx_network_driver.c
@@ -355,7 +355,7 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml)
for (hostPortGroup = hostPortGroupList; hostPortGroup;
hostPortGroup = hostPortGroup->_next) {
if (STREQ(def->portGroups[i].name, hostPortGroup->spec->name)) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_NETWORK_EXIST,
_("HostPortGroup with name '%s' exists already"),
def->portGroups[i].name);
goto cleanup;
@@ -388,7 +388,7 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml)
if (def->forward.ifs[i].type !=
VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_NO_SUPPORT,
_("unsupported device type in network %s "
"interface pool"),
def->name);
diff --git a/src/esx/esx_storage_backend_iscsi.c b/src/esx/esx_storage_backend_iscsi.c
index 395a347cf3..017b800f06 100644
--- a/src/esx/esx_storage_backend_iscsi.c
+++ b/src/esx/esx_storage_backend_iscsi.c
@@ -321,7 +321,7 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags)
if (!target) {
/* pool not found */
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_NO_STORAGE_POOL,
_("Could not find storage pool with name '%s'"),
pool->name);
goto cleanup;
@@ -699,7 +699,7 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume,
}
if (!scsiLun) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_NO_STORAGE_VOL,
_("Could find volume with name: %s"), volume->name);
goto cleanup;
}
diff --git a/src/esx/esx_storage_backend_vmfs.c b/src/esx/esx_storage_backend_vmfs.c
index 4f613bf93b..a98001d6b2 100644
--- a/src/esx/esx_storage_backend_vmfs.c
+++ b/src/esx/esx_storage_backend_vmfs.c
@@ -897,7 +897,7 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
goto cleanup;
if (def->type != VIR_STORAGE_VOL_FILE) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ virReportError(VIR_ERR_NO_SUPPORT, "%s",
_("Creating non-file volumes is not supported"));
goto cleanup;
}
@@ -913,7 +913,7 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
}
if (!virStringHasCaseSuffix(def->name, ".vmdk")) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_NO_SUPPORT,
_("Volume name '%s' has unsupported suffix, "
"expecting '.vmdk'"), def->name);
goto cleanup;
@@ -1032,7 +1032,7 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
key = g_strdup(datastorePath);
}
} else {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_NO_SUPPORT,
_("Creation of %s volumes is not supported"),
virStorageFileFormatTypeToString(def->target.format));
goto cleanup;
@@ -1111,7 +1111,7 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
goto cleanup;
if (def->type != VIR_STORAGE_VOL_FILE) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ virReportError(VIR_ERR_NO_SUPPORT, "%s",
_("Creating non-file volumes is not supported"));
goto cleanup;
}
@@ -1127,7 +1127,7 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
}
if (!virStringHasCaseSuffix(def->name, ".vmdk")) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_NO_SUPPORT,
_("Volume name '%s' has unsupported suffix, "
"expecting '.vmdk'"), def->name);
goto cleanup;
@@ -1212,7 +1212,7 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
key = g_strdup(datastorePath);
}
} else {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_NO_SUPPORT,
_("Creation of %s volumes is not supported"),
virStorageFileFormatTypeToString(def->target.format));
goto cleanup;
diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c
index 11f43acc19..cd3d8925b9 100644
--- a/src/esx/esx_util.c
+++ b/src/esx/esx_util.c
@@ -226,7 +226,7 @@ esxUtil_ParseDatastorePath(const char *datastorePath, char **datastoreName,
/* Expected format: '[<datastore>] <path>' where <path> is optional */
if (!(tmp = STRSKIP(copyOfDatastorePath, "[")) || *tmp == ']' ||
!(preliminaryDatastoreName = strtok_r(tmp, "]", &saveptr))) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_INVALID_ARG,
_("Datastore path '%s' doesn't have expected format "
"'[<datastore>] <path>'"), datastorePath);
goto cleanup;
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index a4f3be02a4..f099716d3e 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -1390,7 +1390,7 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName,
}
}
} else {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_HTTP_ERROR,
_("HTTP response code %d for call to '%s'"),
(*response)->responseCode, methodName);
goto cleanup;
--
2.26.2
4 years, 2 months
[libvirt PATCH v2] esx: generator: fix free of elements in lists
by Pino Toscano
When a list is freed, we iterate through all the items, invoking the
free function for each; the actual free function called for each element
is the function of the actual type of each element, and thus the @_next
pointer in the element struct has the same type as the element itself.
Currently, the free function gets the parent of the current element
type, and invoke its free function to continue freeing the list.
However, in case the hierarchy of the classes has more than 1 level
(i.e. Class <- SubClass <- SubSubClass), the invoked free function is
only the parent class' one, and not the actual base class of the
hierarchy.
To fix that, change the generator to get the base class of a class, and
invoking that instead. Also, avoid to set the @_next back, as it is not
needed.
Fixes commits 5cff36e39ae691fbd7c40597df1732eecf294150 and
f76c6dde2e33233566e886d96e76b5fe0c102d9a.
Signed-off-by: Pino Toscano <ptoscano(a)redhat.com>
---
Changes in v2:
- ancestor -> base class
scripts/esx_vi_generator.py | 26 +++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/scripts/esx_vi_generator.py b/scripts/esx_vi_generator.py
index 863c8af964..e0782e35f3 100755
--- a/scripts/esx_vi_generator.py
+++ b/scripts/esx_vi_generator.py
@@ -751,13 +751,13 @@ class Object(GenericObject):
source += "{\n"
if self.features & Object.FEATURE__LIST:
- if self.extends is not None:
+ base_class = get_base_class(self)
+ if base_class:
# avoid "dereferencing type-punned pointer will break
# strict-aliasing rules" warnings
- source += " esxVI_%s *next = (esxVI_%s *)item->_next;\n\n" \
- % (self.extends, self.extends)
- source += " esxVI_%s_Free(&next);\n" % self.extends
- source += " item->_next = (esxVI_%s *)next;\n\n" % self.name
+ source += " esxVI_%s *baseNext = (esxVI_%s *)item->_next;\n" \
+ % (base_class, base_class)
+ source += " esxVI_%s_Free(&baseNext);\n\n" % base_class
else:
source += " esxVI_%s_Free(&item->_next);\n\n" % self.name
@@ -1250,6 +1250,21 @@ def is_known_type(type):
type in enums_by_name)
+def get_base_class(obj):
+ if not obj.extends:
+ return None
+ base_class = None
+ try:
+ base_class = base_class_by_name[obj.extends]
+ except KeyError:
+ parent = objects_by_name[obj.extends]
+ base_class = get_base_class(parent)
+ if not base_class:
+ base_class = parent.name
+ base_class_by_name[name] = base_class
+ return base_class
+
+
def open_file(filename):
return open(filename, "wt")
@@ -1341,6 +1356,7 @@ managed_objects_by_name = {}
enums_by_name = {}
methods_by_name = {}
block = None
+base_class_by_name = {}
# parse input file
--
2.26.2
4 years, 2 months
[PATCH v2] network: Only check kernel added routes in virNetDevIPCheckIPv6Forwarding
by Ian Wienand
The original motivation for adding virNetDevIPCheckIPv6Forwarding
(00d28a78b5d1f6eaf79f06ac59e31c568af9da37) was that networking routes
would disappear when ipv6 forwarding was enabled for an interface.
This is a fairly undocumented side-effect of the "accept_ra" sysctl
for an interface. 1 means the interface will accept_ra's if not
forwarding, 2 means always accept_RAs; but it is not explained that
enabling forwarding when accept_ra==1 will also clear any kernel RA
assigned routes, very likely breaking your networking.
The check to warn about this currently uses netlink to go through all
the routes and then look at the accept_ra status of the interfaces.
However, it has been noticed that this problem does not affect systems
where IPv6 RA configuration is handled in userspace, e.g. via tools
such as NetworkManager. In this case, the error message from libvirt
is spurious, and modifying the forwarding state will not affect the RA
state or disable your networking.
If you refer to the function rt6_purge_dflt_routers() in the kernel,
we can see that the routes being purged are only those with the
kernel's RTF_ADDRCONF flag set; that is, routes added by the kernel's
RA handling. Why does it do this? I think this is a Linux
implementation decision; it has always been like that and there are
some comments suggesting that it is because a router should be
statically configured, rather than accepting external configurations.
The solution implemented here is to convert the existing check into a
walk of /proc/net/ipv6_route and look for routes with this flag set.
We then check the accept_ra status for the interface, and if enabling
forwarding would break things raise an error.
This should hopefully avoid "interactive" users, who are likely to be
using NetworkManager and the like, having false warnings when enabling
IPv6, but retain the error check for users relying on kernel-based
IPv6 interface auto-configuration.
Signed-off-by: Ian Wienand <iwienand(a)redhat.com>
---
src/util/virnetdevip.c | 323 ++++++++++++++++-------------------------
1 file changed, 124 insertions(+), 199 deletions(-)
diff --git a/src/util/virnetdevip.c b/src/util/virnetdevip.c
index 7bd5a75f85..e208089bd6 100644
--- a/src/util/virnetdevip.c
+++ b/src/util/virnetdevip.c
@@ -43,8 +43,11 @@
#ifdef __linux__
# include <linux/sockios.h>
# include <linux/if_vlan.h>
+# include <linux/ipv6_route.h>
#endif
+#define PROC_NET_IPV6_ROUTE "/proc/net/ipv6_route"
+
#define VIR_FROM_THIS VIR_FROM_NONE
VIR_LOG_INIT("util.netdevip");
@@ -370,203 +373,6 @@ virNetDevIPRouteAdd(const char *ifname,
}
-static int
-virNetDevIPGetAcceptRA(const char *ifname)
-{
- g_autofree char *path = NULL;
- g_autofree char *buf = NULL;
- char *suffix;
- int accept_ra = -1;
-
- path = g_strdup_printf("/proc/sys/net/ipv6/conf/%s/accept_ra",
- ifname ? ifname : "all");
-
- if ((virFileReadAll(path, 512, &buf) < 0) ||
- (virStrToLong_i(buf, &suffix, 10, &accept_ra) < 0))
- return -1;
-
- return accept_ra;
-}
-
-struct virNetDevIPCheckIPv6ForwardingData {
- bool hasRARoutes;
-
- /* Devices with conflicting accept_ra */
- char **devices;
- size_t ndevices;
-};
-
-
-static int
-virNetDevIPCheckIPv6ForwardingAddIF(struct virNetDevIPCheckIPv6ForwardingData *data,
- char **ifname)
-{
- size_t i;
-
- /* add ifname to the array if it's not already there
- * (ifname is char** so VIR_APPEND_ELEMENT() will move the
- * original pointer out of the way and avoid having it freed)
- */
- for (i = 0; i < data->ndevices; i++) {
- if (STREQ(data->devices[i], *ifname))
- return 0;
- }
- return VIR_APPEND_ELEMENT(data->devices, data->ndevices, *ifname);
-}
-
-
-static int
-virNetDevIPCheckIPv6ForwardingCallback(struct nlmsghdr *resp,
- void *opaque)
-{
- struct rtmsg *rtmsg = NLMSG_DATA(resp);
- struct virNetDevIPCheckIPv6ForwardingData *data = opaque;
- struct rtattr *rta_attr;
- int accept_ra = -1;
- int ifindex = -1;
- g_autofree char *ifname = NULL;
-
- /* Ignore messages other than route ones */
- if (resp->nlmsg_type != RTM_NEWROUTE)
- return 0;
-
- /* No need to do anything else for non RA routes */
- if (rtmsg->rtm_protocol != RTPROT_RA)
- return 0;
-
- rta_attr = (struct rtattr *)nlmsg_find_attr(resp, sizeof(struct rtmsg), RTA_OIF);
- if (rta_attr) {
- /* This is a single path route, with interface used to reach
- * nexthop in the RTA_OIF attribute.
- */
- ifindex = *(int *)RTA_DATA(rta_attr);
- ifname = virNetDevGetName(ifindex);
-
- if (!ifname)
- return -1;
-
- accept_ra = virNetDevIPGetAcceptRA(ifname);
-
- VIR_DEBUG("Checking route for device %s (%d), accept_ra: %d",
- ifname, ifindex, accept_ra);
-
- if (accept_ra != 2 && virNetDevIPCheckIPv6ForwardingAddIF(data, &ifname) < 0)
- return -1;
-
- data->hasRARoutes = true;
- return 0;
- }
-
- /* if no RTA_OIF was found, see if this is a multipath route (one
- * which has an array of nexthops, each with its own interface)
- */
-
- rta_attr = (struct rtattr *)nlmsg_find_attr(resp, sizeof(struct rtmsg), RTA_MULTIPATH);
- if (rta_attr) {
- /* The data of the attribute is an array of rtnexthop */
- struct rtnexthop *nh = RTA_DATA(rta_attr);
- size_t len = RTA_PAYLOAD(rta_attr);
-
- /* validate the attribute array length */
- len = MIN(len, ((char *)resp + NLMSG_PAYLOAD(resp, 0) - (char *)rta_attr));
-
- while (len >= sizeof(*nh) && len >= nh->rtnh_len) {
- /* check accept_ra for the interface of each nexthop */
-
- ifname = virNetDevGetName(nh->rtnh_ifindex);
-
- if (!ifname)
- return -1;
-
- accept_ra = virNetDevIPGetAcceptRA(ifname);
-
- VIR_DEBUG("Checking multipath route nexthop device %s (%d), accept_ra: %d",
- ifname, nh->rtnh_ifindex, accept_ra);
-
- if (accept_ra != 2 && virNetDevIPCheckIPv6ForwardingAddIF(data, &ifname) < 0)
- return -1;
-
- VIR_FREE(ifname);
- data->hasRARoutes = true;
-
- len -= NLMSG_ALIGN(nh->rtnh_len);
- VIR_WARNINGS_NO_CAST_ALIGN
- nh = RTNH_NEXT(nh);
- VIR_WARNINGS_RESET
- }
- }
-
- return 0;
-}
-
-bool
-virNetDevIPCheckIPv6Forwarding(void)
-{
- bool valid = false;
- struct rtgenmsg genmsg;
- size_t i;
- struct virNetDevIPCheckIPv6ForwardingData data = {
- .hasRARoutes = false,
- .devices = NULL,
- .ndevices = 0
- };
- g_autoptr(virNetlinkMsg) nlmsg = NULL;
-
-
- /* Prepare the request message */
- if (!(nlmsg = nlmsg_alloc_simple(RTM_GETROUTE,
- NLM_F_REQUEST | NLM_F_DUMP))) {
- virReportOOMError();
- goto cleanup;
- }
-
- memset(&genmsg, 0, sizeof(genmsg));
- genmsg.rtgen_family = AF_INET6;
-
- if (nlmsg_append(nlmsg, &genmsg, sizeof(genmsg), NLMSG_ALIGNTO) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("allocated netlink buffer is too small"));
- goto cleanup;
- }
-
- /* Send the request and loop over the responses */
- if (virNetlinkDumpCommand(nlmsg, virNetDevIPCheckIPv6ForwardingCallback,
- 0, 0, NETLINK_ROUTE, 0, &data) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Failed to loop over IPv6 routes"));
- goto cleanup;
- }
-
- valid = !data.hasRARoutes || data.ndevices == 0;
-
- /* Check the global accept_ra if at least one isn't set on a
- per-device basis */
- if (!valid && data.hasRARoutes) {
- int accept_ra = virNetDevIPGetAcceptRA(NULL);
- valid = accept_ra == 2;
- VIR_DEBUG("Checked global accept_ra: %d", accept_ra);
- }
-
- if (!valid) {
- g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
- for (i = 0; i < data.ndevices; i++) {
- virBufferAdd(&buf, data.devices[i], -1);
- if (i < data.ndevices - 1)
- virBufferAddLit(&buf, ", ");
- }
-
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Check the host setup: enabling IPv6 forwarding with "
- "RA routes without accept_ra set to 2 is likely to cause "
- "routes loss. Interfaces to look at: %s"),
- virBufferCurrentContent(&buf));
- }
-
- cleanup:
- virStringListFreeCount(data.devices, data.ndevices);
- return valid;
-}
-
#else /* defined(__linux__) && defined(WITH_LIBNL) */
@@ -688,15 +494,134 @@ virNetDevIPRouteAdd(const char *ifname,
return 0;
}
+#endif /* defined(__linux__) && defined(HAVE_LIBNL) */
+
+
+#if defined(__linux__)
+
+static int
+virNetDevIPGetAcceptRA(const char *ifname)
+{
+ g_autofree char *path = NULL;
+ g_autofree char *buf = NULL;
+ char *suffix;
+ int accept_ra = -1;
+
+ path = g_strdup_printf("/proc/sys/net/ipv6/conf/%s/accept_ra",
+ ifname ? ifname : "all");
+
+ if ((virFileReadAll(path, 512, &buf) < 0) ||
+ (virStrToLong_i(buf, &suffix, 10, &accept_ra) < 0))
+ return -1;
+
+ return accept_ra;
+}
+
+/**
+ * virNetDevIPCheckIPv6Forwarding
+ *
+ * This function checks if IPv6 routes have the RTF_ADDRCONF flag set,
+ * indicating they have been created by the kernel's RA configuration
+ * handling. These routes are subject to being flushed when ipv6
+ * forwarding is enabled unless accept_ra is explicitly set to "2".
+ * This will most likely result in ipv6 networking being broken.
+ *
+ * Returns: true if it is safe to enable forwarding, or false if
+ * breakable routes are found.
+ *
+ **/
+bool
+virNetDevIPCheckIPv6Forwarding(void)
+{
+ int len;
+ char *cur;
+ g_autofree char *buf = NULL;
+ /* lines are 150 chars */
+ enum {MAX_ROUTE_SIZE = 150*100000};
+
+ /* This is /proc/sys/net/ipv6/conf/all/accept_ra */
+ int all_accept_ra = virNetDevIPGetAcceptRA(NULL);
+
+ /* Read ipv6 routes */
+ if ((len = virFileReadAll(PROC_NET_IPV6_ROUTE,
+ MAX_ROUTE_SIZE, &buf)) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unable to read %s "
+ "for ipv6 forwarding checks"), PROC_NET_IPV6_ROUTE);
+ return false;
+ }
+
+ /* VIR_DEBUG("%s output:\n%s", PROC_NET_IPV6_ROUTE, buf); */
+
+ /* Dropping the last character to stop the loop */
+ if (len > 0)
+ buf[len-1] = '\0';
+
+ cur = buf;
+ while (cur) {
+ char route[33], flags[9], iface[9];
+ unsigned int flags_val;
+ char *iface_val;
+ int num;
+ char *nl = strchr(cur, '\n');
+
+ if (nl)
+ *nl++ = '\0';
+
+ num = sscanf(cur, "%32s %*s %*s %*s %*s %*s %*s %*s %8s %8s",
+ route, flags, iface);
+
+ cur = nl;
+ if (num != 3) {
+ VIR_DEBUG("Failed to parse route line: %s", cur);
+ continue;
+ }
+
+ if (virStrToLong_ui(flags, NULL, 16, &flags_val)) {
+ VIR_DEBUG("Failed to parse flags: %s", flags);
+ continue;
+ }
+
+ /* This is right justified, strip leading spaces */
+ iface_val = &iface[0];
+ while (*iface_val && g_ascii_isspace(*iface_val))
+ iface_val++;
+
+ VIR_DEBUG("%s iface %s flags %s : RTF_ADDRCONF %sset",
+ route, iface_val, flags,
+ (flags_val & RTF_ADDRCONF ? "" : "not "));
+
+ if (flags_val & RTF_ADDRCONF) {
+ int ret = virNetDevIPGetAcceptRA(iface_val);
+ VIR_DEBUG("%s reports accept_ra of %d",
+ iface_val, ret);
+ /* If the interface for this autoconfigured route
+ * has accept_ra == 1, or it is default and the "all"
+ * value of accept_ra == 1, it will be subject to
+ * flushing if forwarding is enabled.
+ */
+ if (ret == 1 || (ret == 0 && all_accept_ra == 1)) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Check the host setup: interface %s has kernel "
+ "autoconfigured IPv6 routes and enabling forwarding "
+ " without accept_ra set to 2 will cause the kernel "
+ "to flush them, breaking networking."), iface_val);
+ return false;
+ }
+ }
+ }
+ return true;
+}
+#else
bool
virNetDevIPCheckIPv6Forwarding(void)
{
- VIR_WARN("built without libnl: unable to check if IPv6 forwarding can be safely enabled");
+ VIR_DEBUG("No checks for IPv6 forwarding issues on non-Linux systems", flags);
return true;
}
-#endif /* defined(__linux__) && defined(WITH_LIBNL) */
+#endif /* defined(__linux__) */
/**
--
2.26.2
4 years, 2 months
[libvirt PATCH v3 0/3] Add support for vDPA network devices
by Jonathon Jongsma
vDPA network devices allow high-performance networking in a virtual machine by
providing a wire-speed data path. These devices require a vendor-specific host
driver but the data path follows the virtio specification.
The support for vDPA devices was recently added to qemu. This allows
libvirt to support these devices. This patchset requires that the device is
configured on the host with the appropriate vendor-specific driver. This will
create a chardev on the host at e.g. /dev/vhost-vdpa-0. That chardev path can
then be used to define a new interface with type='vdpa'.
Changes in v3:
- rebased to latest master
- various small fixes per comments on last review
- investigated hotplug -- I have a preliminary libvirt patch, but it doesn't
appear that hotplug is fully supported in qemu yet.
- qemu never closes the fd when the device is removed, so the device cannot
be reassigned to a different domain.
- I decided not to post the preliminary hotplug patch until I can get more
clarity from qemu developers.
Jonathon Jongsma (3):
conf: Add support for vDPA network devices
qemu: add vhost-vdpa capability
qemu: add vdpa support
docs/formatdomain.rst | 24 ++++++++++++
docs/schemas/domaincommon.rng | 15 ++++++++
src/conf/domain_conf.c | 31 ++++++++++++++++
src/conf/domain_conf.h | 4 ++
src/conf/netdev_bandwidth_conf.c | 1 +
src/libxl/libxl_conf.c | 1 +
src/libxl/xen_common.c | 1 +
src/lxc/lxc_controller.c | 1 +
src/lxc/lxc_driver.c | 3 ++
src/lxc/lxc_process.c | 1 +
src/qemu/qemu_capabilities.c | 4 ++
src/qemu/qemu_capabilities.h | 3 ++
src/qemu/qemu_command.c | 31 +++++++++++++++-
src/qemu/qemu_command.h | 3 +-
src/qemu/qemu_domain.c | 6 ++-
src/qemu/qemu_hotplug.c | 15 +++++---
src/qemu/qemu_interface.c | 25 +++++++++++++
src/qemu/qemu_interface.h | 2 +
src/qemu/qemu_migration.c | 10 ++++-
src/qemu/qemu_process.c | 2 +
src/qemu/qemu_validate.c | 15 ++++++++
src/vmx/vmx.c | 1 +
.../caps_5.1.0.x86_64.xml | 1 +
.../caps_5.2.0.x86_64.xml | 1 +
.../net-vdpa.x86_64-latest.args | 37 +++++++++++++++++++
tests/qemuxml2argvdata/net-vdpa.xml | 28 ++++++++++++++
tests/qemuxml2argvmock.c | 11 +++++-
tests/qemuxml2argvtest.c | 1 +
tests/qemuxml2xmloutdata/net-vdpa.xml | 34 +++++++++++++++++
tests/qemuxml2xmltest.c | 1 +
tools/virsh-domain.c | 1 +
31 files changed, 303 insertions(+), 11 deletions(-)
create mode 100644 tests/qemuxml2argvdata/net-vdpa.x86_64-latest.args
create mode 100644 tests/qemuxml2argvdata/net-vdpa.xml
create mode 100644 tests/qemuxml2xmloutdata/net-vdpa.xml
--
2.26.2
4 years, 2 months
[PATCH v2 0/7] qemu: implementation of transient disk option
by Masayoshi Mizuma
This patchset tries to implement transient option for qcow2 and raw
format disk. This uses the snapshot cleanup codes:
https://www.redhat.com/archives/libvir-list/2020-August/msg00299.html
It gets user available to set <transient/> to the domain xml file like as:
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/var/lib/libvirt/images/guest.qcow2'/>
<target dev='vda' bus='virtio'/>
<transient/>
</disk>
Any changes which the Guest does to the disk is dropped when the Guest
is shutdowned.
There are some limitations for transient disk option so far:
- Supported disk format is qcow2 and raw
- blockdev capability is required for qemu
- Following features are blocked with transient disk option
- blockjobs
- Migration
- Disk hotplug
Masayoshi Mizuma (7):
qemuSnapshotDiskPrepareOne: Get available even if snapdisk is NULL
qemu: Introduce functions to handle transient disk
qemu: Add transient disk handler to start and stop the guest
qemu: Transient option gets avaiable for qcow2 and raw format disk
qemu: Block blockjobs when transient disk option is enabled
qemu: Block migration when transient disk option is enabled
qemu: Block disk hotplug when transient disk option is enabled
src/qemu/qemu_domain.c | 7 ++
src/qemu/qemu_hotplug.c | 6 ++
src/qemu/qemu_migration.c | 22 ++++++
src/qemu/qemu_process.c | 8 +++
src/qemu/qemu_snapshot.c | 139 +++++++++++++++++++++++++++++++++++++-
src/qemu/qemu_snapshot.h | 8 +++
src/qemu/qemu_validate.c | 9 ++-
src/util/virstoragefile.h | 2 +
8 files changed, 196 insertions(+), 5 deletions(-)
--
2.27.0
4 years, 2 months
[libvirt PATCH] esx: implement domainGetHostname
by Pino Toscano
Implement the .domainGetHostname hypervisor driver API to get the
hostname of a running guest (needs VMware Tools).
Signed-off-by: Pino Toscano <ptoscano(a)redhat.com>
---
docs/drvesx.html.in | 3 +++
src/esx/esx_driver.c | 54 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 57 insertions(+)
diff --git a/docs/drvesx.html.in b/docs/drvesx.html.in
index e25cf07e92..38de640c2a 100644
--- a/docs/drvesx.html.in
+++ b/docs/drvesx.html.in
@@ -796,6 +796,9 @@ Enter administrator password for example-vcenter.com:
performed the ESX server raises an error and the driver reports it.
</p>
<ul>
+ <li>
+ <code>virDomainGetHostname</code>
+ </li>
<li>
<code>virDomainReboot</code>
</li>
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 9080478435..bddc588977 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -5060,6 +5060,59 @@ esxDomainHasManagedSaveImage(virDomainPtr domain, unsigned int flags)
}
+static char *
+esxDomainGetHostname(virDomainPtr domain,
+ unsigned int flags)
+{
+ esxPrivate *priv = domain->conn->privateData;
+ esxVI_String *propertyNameList = NULL;
+ esxVI_ObjectContent *virtualMachine = NULL;
+ esxVI_VirtualMachinePowerState powerState;
+ char *hostname = NULL;
+ char *new_hostname = NULL;
+
+ virCheckFlags(0, NULL);
+
+ if (esxVI_EnsureSession(priv->primary) < 0)
+ return NULL;
+
+ if (esxVI_String_AppendValueListToList(&propertyNameList,
+ "runtime.powerState\0"
+ "guest.hostName") < 0 ||
+ esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid,
+ propertyNameList, &virtualMachine,
+ esxVI_Occurrence_OptionalItem) ||
+ esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) {
+ goto cleanup;
+ }
+
+ if (powerState != esxVI_VirtualMachinePowerState_PoweredOn) {
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+ _("Domain is not powered on"));
+ goto cleanup;
+ }
+
+ if (esxVI_GetStringValue(virtualMachine, "guest.hostName",
+ &hostname, esxVI_Occurrence_OptionalItem) < 0) {
+ goto cleanup;
+ }
+
+ if (!hostname) {
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+ _("hostName field not available (missing VMware Tools?)"));
+ goto cleanup;
+ }
+
+ new_hostname = g_strdup(hostname);
+
+ cleanup:
+ esxVI_String_Free(&propertyNameList);
+ esxVI_ObjectContent_Free(&virtualMachine);
+
+ return new_hostname;
+}
+
+
static virHypervisorDriver esxHypervisorDriver = {
.name = "ESX",
.connectOpen = esxConnectOpen, /* 0.7.0 */
@@ -5140,6 +5193,7 @@ static virHypervisorDriver esxHypervisorDriver = {
.domainSnapshotDelete = esxDomainSnapshotDelete, /* 0.8.0 */
.connectIsAlive = esxConnectIsAlive, /* 0.9.8 */
.domainHasManagedSaveImage = esxDomainHasManagedSaveImage, /* 1.2.13 */
+ .domainGetHostname = esxDomainGetHostname, /* 6.8.0 */
};
--
2.26.2
4 years, 2 months
[PATCH 0/3] numa: cleanups for 5.2
by Igor Mammedov
Remove deprecated default RAM splitting beween numa
nodes that was deprecated since 4.1, and a couple of
minor numa clean ups.
Igor Mammedov (3):
numa: drop support for '-numa node' (without memory specified)
doc: Cleanup "'-mem-path' fallback to RAM" deprecation text
numa: remove fixup numa_state->num_nodes to MAX_NODES
include/hw/boards.h | 2 --
include/sysemu/numa.h | 4 ---
docs/system/deprecated.rst | 44 +++++++++++++++-------------
hw/core/machine.c | 1 -
hw/core/numa.c | 59 --------------------------------------
hw/i386/pc_piix.c | 1 -
hw/i386/pc_q35.c | 1 -
hw/ppc/spapr.c | 1 -
8 files changed, 24 insertions(+), 89 deletions(-)
--
2.27.0
4 years, 2 months