[libvirt PATCH 7/7] NEWS: Mention systemd-resolved support in network driver
Signed-off-by: Jiri Denemark --- NEWS.rst | 7 +++ 1 file changed, 7 insertions(+) diff --git a/NEWS.rst b/NEWS.rst index e2796fd8b2..15b0da31b6 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -23,6 +23,13 @@ v10.1.0 (unreleased) Additionally, if CPU clusters are present in the host topology, they will be reported as part of the capabilities XML. + * network: Make virtual domains resolvable from the host + +When starting a virtual network with a new ``register='yes'`` attribute +in the element, libvirt will configure ``systemd-resolved`` +to resolve names of the connected guests using the name server started +for this network. + * **Improvements** * **Bug fixes** -- 2.43.0 ___ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-le...@lists.libvirt.org
[libvirt PATCH 6/7] network: Make virtual domains resolvable from the host
This patch adds a new attribute "register" to the element. If set to "yes", the DNS server created for the virtual network is registered with systemd-resolved as a name server for the associated domain. The names known to the dnsmasq process serving DNS and DHCP requests for the virtual network will then be resolvable from the host by appending the domain name to them. Signed-off-by: Jiri Denemark --- docs/formatnetwork.rst | 9 - src/conf/network_conf.c | 18 ++ src/conf/network_conf.h | 1 + src/conf/schemas/network.rng | 3 +++ src/network/bridge_driver.c | 32 +++- 5 files changed, 61 insertions(+), 2 deletions(-) diff --git a/docs/formatnetwork.rst b/docs/formatnetwork.rst index 16e81246fa..dcdaf1e5a5 100644 --- a/docs/formatnetwork.rst +++ b/docs/formatnetwork.rst @@ -88,7 +88,7 @@ to the physical LAN (if at all). ... - + ... @@ -162,6 +162,13 @@ to the physical LAN (if at all). DNS server. If ``localOnly`` is "no", and by default, unresolved requests **will** be forwarded. :since:`Since 1.2.12` + :since:`Since 10.1.0` the optional ``register`` attribute can be used to + request registering the DNS server for resolving this domain with the host's + DNS resolver. When set to "yes", the host resolver will forward all requests + for domain names from this domain to the DNS server created for this virtual + network. To avoid DNS loops ``localOnly`` has to be set to "yes" as well. + This feature requires ``systemd-resolved`` to be running on the host. + ``forward`` Inclusion of the ``forward`` element indicates that the virtual network is to be connected to the physical LAN. :since:`Since 0.3.0.` The ``mode`` diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index ef3415cd89..cc92ed0b03 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -1582,6 +1582,19 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt, >domainLocalOnly) < 0) return NULL; +if (virXMLPropTristateBool(domain_node, "register", + VIR_XML_PROP_NONE, + >domainRegister) < 0) +return NULL; + +if (def->domainRegister == VIR_TRISTATE_BOOL_YES && +def->domainLocalOnly != VIR_TRISTATE_BOOL_YES) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("attribute 'register=yes' in element requires 'localOnly=yes' in network %1$s"), + def->name); +return NULL; +} + if ((bandwidthNode = virXPathNode("./bandwidth", ctxt)) && virNetDevBandwidthParse(>bandwidth, NULL, bandwidthNode, false) < 0) return NULL; @@ -2405,6 +2418,11 @@ virNetworkDefFormatBuf(virBuffer *buf, virBufferAsprintf(buf, " localOnly='%s'", local); } +if (def->domainRegister) { +virBufferAsprintf(buf, " register='%s'", + virTristateBoolTypeToString(def->domainRegister)); +} + virBufferAddLit(buf, "/>\n"); } diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h index 1d7fd3ab6a..c2a4198abc 100644 --- a/src/conf/network_conf.h +++ b/src/conf/network_conf.h @@ -245,6 +245,7 @@ struct _virNetworkDef { int macTableManager; /* enum virNetworkBridgeMACTableManager */ char *domain; virTristateBool domainLocalOnly; /* yes disables dns forwarding */ +virTristateBool domainRegister; unsigned long delay; /* Bridge forward delay (ms) */ bool stp; /* Spanning tree protocol */ unsigned int mtu; /* MTU for bridge, 0 means "default" i.e. unset in config */ diff --git a/src/conf/schemas/network.rng b/src/conf/schemas/network.rng index e56e07d130..b7c8551fad 100644 --- a/src/conf/schemas/network.rng +++ b/src/conf/schemas/network.rng @@ -258,6 +258,9 @@ + + + diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 9921c7cd14..d89700c6ee 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -63,7 +63,7 @@ #include "virjson.h" #include "virnetworkportdef.h" #include "virutil.h" - +#include "virsystemd.h" #include "netdev_bandwidth_conf.h" #define VIR_FROM_THIS VIR_FROM_NETWORK @@ -1902,6 +1902,7 @@ networkStartNetworkVirtual(virNetworkDriverState *driver, bool dnsmasqStarted = false; bool devOnline = false; bool firewalRulesAdded = false; +virSocketAddr *dnsServer = NULL; /* Check to see if any network IP collides with an existing route */ if (networkCheckRouteCollision(def) < 0) @@ -1958,6 +1959,9 @@ networkStartNetworkVirtual(virNetworkDriverState *driver, if (VIR_SOCKET_ADDR_IS_FAMILY(>address, AF_INET6)) v6present = true; +if (!dnsServer) +dnsServer =
[libvirt PATCH 5/7] tests: Add tests for virSystemdResolvedRegisterNameServer
Signed-off-by: Jiri Denemark --- tests/virsystemdtest.c | 147 + 1 file changed, 147 insertions(+) diff --git a/tests/virsystemdtest.c b/tests/virsystemdtest.c index fcd76514e1..004b0549ce 100644 --- a/tests/virsystemdtest.c +++ b/tests/virsystemdtest.c @@ -87,6 +87,34 @@ VIR_MOCK_WRAP_RET_ARGS(g_dbus_connection_call_sync, reply = g_variant_new("()"); } } +} else if (STREQ(bus_name, "org.freedesktop.resolve1")) { +g_autofree char *actual = NULL; + +if (getenv("FAIL_BAD_SERVICE")) { +*error = g_dbus_error_new_for_dbus_error("org.freedesktop.systemd.badthing", + "Contacting resolved failed"); +} else if (STREQ(method_name, "SetLinkDomains")) { +const char *expected = getenv("TEST_RESOLVED_LINK_DOMAINS"); +actual = g_variant_print(params, FALSE); + +if (virTestCompareToString(expected, actual) < 0) +*error = g_dbus_error_new_for_dbus_error("org.freedesktop.systemd.badthing", + "Unexpected params to SetLinkDomains"); +else +reply = g_variant_new("()"); +} else if (STREQ(method_name, "SetLinkDNS")) { +const char *expected = getenv("TEST_RESOLVED_LINK_DNS"); +actual = g_variant_print(params, FALSE); + +if (virTestCompareToString(expected, actual) < 0) +*error = g_dbus_error_new_for_dbus_error("org.freedesktop.systemd.badthing", + "Unexpected params to SetLinkDNS"); +else +reply = g_variant_new("()"); +} else { +*error = g_dbus_error_new_for_dbus_error("org.freedesktop.systemd.badthing", + "Unknown resolved method"); +} } else if (STREQ(bus_name, "org.freedesktop.login1")) { reply = g_variant_new("(s)", getenv("RESULT_SUPPORT")); } else if (STREQ(bus_name, "org.freedesktop.DBus") && @@ -100,6 +128,7 @@ VIR_MOCK_WRAP_RET_ARGS(g_dbus_connection_call_sync, if (!getenv("FAIL_NO_SERVICE")) { g_variant_builder_add(, "s", "org.freedesktop.machine1"); g_variant_builder_add(, "s", "org.freedesktop.login1"); +g_variant_builder_add(, "s", "org.freedesktop.resolve1"); } reply = g_variant_new("(@as)", g_variant_builder_end()); @@ -114,6 +143,7 @@ VIR_MOCK_WRAP_RET_ARGS(g_dbus_connection_call_sync, if (!getenv("FAIL_NO_SERVICE") && !getenv("FAIL_NOT_REGISTERED")) { g_variant_builder_add(, "s", "org.freedesktop.systemd1"); g_variant_builder_add(, "s", "org.freedesktop.login1"); +g_variant_builder_add(, "s", "org.freedesktop.resolve1"); } reply = g_variant_new("(@as)", g_variant_builder_end()); @@ -613,6 +643,83 @@ testActivationEmpty(const void *opaque G_GNUC_UNUSED) return 0; } + +struct testResolvedData { +int link; +const char *env; +const char *dom; +const char *addr; +const char *expDomains; +const char *expDNS; +}; + + +static int +testResolvedFailed(const void *opaque) +{ +const struct testResolvedData *data = opaque; +virSocketAddr addr = {0}; +int ret = -1; +int expected = -2; +int rv; + +if (!data->env) { +fprintf(stderr, "%s", +"testResolvedFailed called without environment variable name"); +return -1; +} + +if (data->addr && +virSocketAddrParse(, data->addr, AF_UNSPEC) < 0) +return -1; + +if (STREQ(data->env, "FAIL_BAD_SERVICE")) +expected = -1; + +g_setenv(data->env, "1", TRUE); + +rv = virSystemdResolvedRegisterNameServer(data->link, data->dom, ); + +if (rv == 0) +fprintf(stderr, "%s", "Updating resolved succeeded unexpectedly\n"); +else if (rv != expected) +fprintf(stderr, "%s", "Updating resolved failed unexpectedly\n"); +else +ret = 0; + +g_unsetenv(data->env); +return ret; +} + + +static int +testResolved(const void *opaque) +{ +const struct testResolvedData *data = opaque; +virSocketAddr addr = {0}; +int ret = -1; + +if (data->addr && +virSocketAddrParse(, data->addr, AF_UNSPEC) < 0) +return -1; + +g_setenv("TEST_RESOLVED_LINK_DOMAINS", data->expDomains, TRUE); +g_setenv("TEST_RESOLVED_LINK_DNS", data->expDNS, TRUE); + +if (virSystemdResolvedRegisterNameServer(data->link, data->dom, ) < 0) { +fprintf(stderr, "%s", "Updating resolved failed unexpectedly\n"); +goto cleanup; +} + +ret = 0; + + cleanup: +g_unsetenv("TEST_RESOLVED_LINK_DOMAINS"); +g_unsetenv("TEST_RESOLVED_LINK_DNS"); +return ret; +} + + static int mymain(void) { @@ -732,6 +839,46 @@ mymain(void)
[libvirt PATCH 4/7] util: Introduce virSystemdResolvedRegisterNameServer
Signed-off-by: Jiri Denemark --- src/libvirt_private.syms | 1 + src/util/virsystemd.c| 79 +++- src/util/virsystemd.h| 5 +++ 3 files changed, 84 insertions(+), 1 deletion(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 0be273511d..d8c566b458 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3485,6 +3485,7 @@ virSystemdHasResolvedResetCachedValue; virSystemdMakeScopeName; virSystemdMakeSliceName; virSystemdNotifyStartup; +virSystemdResolvedRegisterNameServer; virSystemdTerminateMachine; diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c index 0dfc4398d0..68699929d3 100644 --- a/src/util/virsystemd.c +++ b/src/util/virsystemd.c @@ -34,7 +34,6 @@ #include "virerror.h" #include "virfile.h" #include "virhash.h" -#include "virsocketaddr.h" #define VIR_FROM_THIS VIR_FROM_SYSTEMD @@ -1042,3 +1041,81 @@ virSystemdActivationFree(virSystemdActivation *act) g_free(act); } + + +/** + * virSystemdResolvedRegisterNameServer: + * @link: network interface ID + * @domain: registered domain + * @addr: address the DNS server is listening on + * + * Talk to systemd-resolved and register a DNS server listening on @addr + * as a resolver for @domain. This configuration is bound to @link interface + * and automatically dropped when the interface goes away. + * + * Returns -2 when systemd-resolved is unavailable, + * -1 on error, + * 0 on success. + */ +int +virSystemdResolvedRegisterNameServer(int link, + const char *domain, + virSocketAddr *addr) +{ +int rc; +GDBusConnection *conn; +GVariant *params; +GVariant *byteArray; +unsigned char addrBytes[16]; +int nBytes; + +if ((rc = virSystemdHasResolved()) < 0) +return rc; + +if (!(conn = virGDBusGetSystemBus())) +return -1; + +/* + * SetLinkDomains(in i ifindex, + *in a(sb) domains); + */ +params = g_variant_new_parsed("(%i, [(%s, true)])", + (gint32) link, + domain); + +rc = virGDBusCallMethod(conn, NULL, NULL, NULL, +"org.freedesktop.resolve1", +"/org/freedesktop/resolve1", +"org.freedesktop.resolve1.Manager", +"SetLinkDomains", +params); +g_variant_unref(params); + +if (rc < 0) +return -1; + +/* + * SetLinkDNS(in i ifindex, + *in a(iay) addresses); + */ +nBytes = virSocketAddrBytes(addr, addrBytes, sizeof(addrBytes)); +byteArray = g_variant_new_fixed_array(G_VARIANT_TYPE("y"), + addrBytes, nBytes, 1); +params = g_variant_new_parsed("(%i, [(%i, %@ay)])", + (gint32) link, + VIR_SOCKET_ADDR_FAMILY(addr), + byteArray); + +rc = virGDBusCallMethod(conn, NULL, NULL, NULL, +"org.freedesktop.resolve1", +"/org/freedesktop/resolve1", +"org.freedesktop.resolve1.Manager", +"SetLinkDNS", +params); +g_variant_unref(params); + +if (rc < 0) +return -1; + +return 0; +} diff --git a/src/util/virsystemd.h b/src/util/virsystemd.h index 65add8b5b9..b7fdaf67df 100644 --- a/src/util/virsystemd.h +++ b/src/util/virsystemd.h @@ -22,6 +22,7 @@ #pragma once #include "internal.h" +#include "virsocketaddr.h" typedef struct _virSystemdActivation virSystemdActivation; @@ -76,3 +77,7 @@ void virSystemdActivationClaimFDs(virSystemdActivation *act, void virSystemdActivationFree(virSystemdActivation *act); G_DEFINE_AUTOPTR_CLEANUP_FUNC(virSystemdActivation, virSystemdActivationFree); + +int virSystemdResolvedRegisterNameServer(int link, + const char *domain, + virSocketAddr *addr); -- 2.43.0 ___ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-le...@lists.libvirt.org
[libvirt PATCH 3/7] util: Introduce virSocketAddrBytes
Signed-off-by: Jiri Denemark --- src/libvirt_private.syms | 1 + src/util/virsocketaddr.c | 63 src/util/virsocketaddr.h | 4 +++ 3 files changed, 68 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 6b4fe17e20..0be273511d 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3368,6 +3368,7 @@ virSocketSendFD; # util/virsocketaddr.h virSocketAddrBroadcast; virSocketAddrBroadcastByPrefix; +virSocketAddrBytes; virSocketAddrCheckNetmask; virSocketAddrEqual; virSocketAddrFormat; diff --git a/src/util/virsocketaddr.c b/src/util/virsocketaddr.c index fbda858cfe..0a1ae1ac5f 100644 --- a/src/util/virsocketaddr.c +++ b/src/util/virsocketaddr.c @@ -30,6 +30,7 @@ */ typedef unsigned char virSocketAddrIPv4[4]; typedef unsigned short virSocketAddrIPv6[8]; +typedef unsigned char virSocketAddrIPv6Bytes[16]; typedef unsigned char virSocketAddrIPv6Nibbles[32]; static int @@ -68,6 +69,23 @@ virSocketAddrGetIPv6Addr(const virSocketAddr *addr, virSocketAddrIPv6 *tab) return 0; } + +static int +virSocketAddrGetIPv6Bytes(const virSocketAddr *addr, + virSocketAddrIPv6Bytes *tab) +{ +size_t i; + +if (!addr || !tab || addr->data.stor.ss_family != AF_INET6) +return -1; + +for (i = 0; i < 16; i++) +(*tab)[i] = addr->data.inet6.sin6_addr.s6_addr[i]; + +return 0; +} + + static int virSocketAddrGetIPv6Nibbles(const virSocketAddr *addr, virSocketAddrIPv6Nibbles *tab) @@ -1331,6 +1349,51 @@ virSocketAddrPTRDomain(const virSocketAddr *addr, return 0; } + +/** + * virSocketAddrBytes: + * @addr: address to convert to byte array + * @bytes: a preallocated array to store the address bytes to + * @maxBytes: the size of @bytes + * + * Extracts individual bytes of an IPv4 or IPv6 address in the provided @bytes + * array, which should be large enough to store 16 bytes (the size of an IPv6 + * address). Bytes are stored in network order. + * + * Returns the number of bytes stored in @bytes on success or 0 when @bytes + * array is not big enough or @addr is not IPv4 or IPv6. + */ +int +virSocketAddrBytes(const virSocketAddr *addr, + unsigned char *bytes, + int maxBytes) +{ +if (VIR_SOCKET_ADDR_IS_FAMILY(addr, AF_INET6)) { +virSocketAddrIPv6Bytes ip; + +if (maxBytes < sizeof(ip)) +return 0; + +virSocketAddrGetIPv6Bytes(addr, ); +memcpy(bytes, ip, sizeof(ip)); +return sizeof(ip); +} + +if (VIR_SOCKET_ADDR_IS_FAMILY(addr, AF_INET)) { +virSocketAddrIPv4 ip; + +if (maxBytes < sizeof(ip)) +return 0; + +virSocketAddrGetIPv4Addr(addr, ); +memcpy(bytes, ip, sizeof(ip)); +return sizeof(ip); +} + +return 0; +} + + void virSocketAddrFree(virSocketAddr *addr) { diff --git a/src/util/virsocketaddr.h b/src/util/virsocketaddr.h index ec265d6e44..47b8effa85 100644 --- a/src/util/virsocketaddr.h +++ b/src/util/virsocketaddr.h @@ -143,6 +143,10 @@ int virSocketAddrPTRDomain(const virSocketAddr *addr, char **ptr) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3); +int virSocketAddrBytes(const virSocketAddr *addr, + unsigned char *bytes, + int maxBytes); + void virSocketAddrFree(virSocketAddr *addr); G_DEFINE_AUTOPTR_CLEANUP_FUNC(virSocketAddr, virSocketAddrFree); -- 2.43.0 ___ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-le...@lists.libvirt.org
[libvirt PATCH 2/7] util: Introduce virSystemdHasResolved
Signed-off-by: Jiri Denemark --- src/libvirt_private.syms | 2 ++ src/util/virsystemd.c | 15 +++ src/util/virsystemd.h | 2 ++ src/util/virsystemdpriv.h | 1 + 4 files changed, 20 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 2ebc0de212..6b4fe17e20 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3479,6 +3479,8 @@ virSystemdHasLogind; virSystemdHasLogindResetCachedValue; virSystemdHasMachined; virSystemdHasMachinedResetCachedValue; +virSystemdHasResolved; +virSystemdHasResolvedResetCachedValue; virSystemdMakeScopeName; virSystemdMakeSliceName; virSystemdNotifyStartup; diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c index 21892aca02..0dfc4398d0 100644 --- a/src/util/virsystemd.c +++ b/src/util/virsystemd.c @@ -127,6 +127,7 @@ char *virSystemdMakeSliceName(const char *partition) static int virSystemdHasMachinedCachedValue = -1; static int virSystemdHasLogindCachedValue = -1; +static int virSystemdHasResolvedCachedValue = -1; /* Reset the cache from tests for testing the underlying dbus calls * as well */ @@ -140,6 +141,12 @@ void virSystemdHasLogindResetCachedValue(void) virSystemdHasLogindCachedValue = -1; } +void +virSystemdHasResolvedResetCachedValue(void) +{ +virSystemdHasResolvedCachedValue = -1; +} + /** * virSystemdHasService: @@ -200,6 +207,14 @@ virSystemdHasLogind(void) } +int +virSystemdHasResolved(void) +{ +return virSystemdHasService("org.freedesktop.resolve1", false, +); +} + + /** * virSystemdGetMachineByPID: * @conn: dbus connection diff --git a/src/util/virsystemd.h b/src/util/virsystemd.h index 19fb714132..65add8b5b9 100644 --- a/src/util/virsystemd.h +++ b/src/util/virsystemd.h @@ -49,6 +49,8 @@ int virSystemdHasMachined(void); int virSystemdHasLogind(void); +int virSystemdHasResolved(void); + int virSystemdCanSuspend(bool *result); int virSystemdCanHibernate(bool *result); diff --git a/src/util/virsystemdpriv.h b/src/util/virsystemdpriv.h index 736c53d3fa..1f1dda456c 100644 --- a/src/util/virsystemdpriv.h +++ b/src/util/virsystemdpriv.h @@ -29,3 +29,4 @@ void virSystemdHasMachinedResetCachedValue(void); void virSystemdHasLogindResetCachedValue(void); +void virSystemdHasResolvedResetCachedValue(void); -- 2.43.0 ___ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-le...@lists.libvirt.org
[libvirt PATCH 1/7] util: Refactor virSystemdHas{Machined,Logind}
To reduce code duplication both function now use a common virSystemdHasService helper. Signed-off-by: Jiri Denemark --- src/util/virsystemd.c | 76 --- 1 file changed, 36 insertions(+), 40 deletions(-) diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c index cd4de0eef8..21892aca02 100644 --- a/src/util/virsystemd.c +++ b/src/util/virsystemd.c @@ -141,66 +141,62 @@ void virSystemdHasLogindResetCachedValue(void) } -/* -2 = machine1 is not supported on this machine - * -1 = error - * 0 = machine1 is available +/** + * virSystemdHasService: + * + * Check whether a DBus @service is enabled and either the service itself or + * systemd1 service is registered. If @requireSystemd == true, the systemd1 + * service has to be registered even if @service is registered. + * + * Returns + * -2 when service is not supported on this machine + * -1 on error + *0 when service is available */ -int -virSystemdHasMachined(void) +static int +virSystemdHasService(const char *service, + bool requireSystemd, + int *cached) { int ret; int val; -val = g_atomic_int_get(); +val = g_atomic_int_get(cached); if (val != -1) return val; -if ((ret = virGDBusIsServiceEnabled("org.freedesktop.machine1")) < 0) { +if ((ret = virGDBusIsServiceEnabled(service)) < 0) { if (ret == -2) -g_atomic_int_set(, -2); +g_atomic_int_set(cached, -2); return ret; } -if ((ret = virGDBusIsServiceRegistered("org.freedesktop.systemd1")) == -1) +if ((ret = virGDBusIsServiceRegistered(service)) == -1) return ret; -g_atomic_int_set(, ret); + +if (requireSystemd || ret == -2) { +if ((ret = virGDBusIsServiceRegistered("org.freedesktop.systemd1")) == -1) +return ret; +} + +g_atomic_int_set(cached, ret); return ret; } + int -virSystemdHasLogind(void) +virSystemdHasMachined(void) { -int ret; -int val; - -val = g_atomic_int_get(); -if (val != -1) -return val; - -ret = virGDBusIsServiceEnabled("org.freedesktop.login1"); -if (ret < 0) { -if (ret == -2) -g_atomic_int_set(, -2); -return ret; -} - -/* - * Want to use logind if: - * - logind is already running - * Or - * - logind is not running, but this is a systemd host - * (rely on dbus activation) - */ -if ((ret = virGDBusIsServiceRegistered("org.freedesktop.login1")) == -1) -return ret; +return virSystemdHasService("org.freedesktop.machine1", true, +); +} -if (ret == -2) { -if ((ret = virGDBusIsServiceRegistered("org.freedesktop.systemd1")) == -1) -return ret; -} -g_atomic_int_set(, ret); -return ret; +int +virSystemdHasLogind(void) +{ +return virSystemdHasService("org.freedesktop.login1", false, +); } -- 2.43.0 ___ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-le...@lists.libvirt.org
[libvirt PATCH 0/7] Configure systemd-resolved when starting networks
See 6/7 for more details. Jiri Denemark (7): util: Refactor virSystemdHas{Machined,Logind} util: Introduce virSystemdHasResolved util: Introduce virSocketAddrBytes util: Introduce virSystemdResolvedRegisterNameServer tests: Add tests for virSystemdResolvedRegisterNameServer network: Make virtual domains resolvable from the host NEWS: Mention systemd-resolved support in network driver NEWS.rst | 7 ++ docs/formatnetwork.rst | 9 +- src/conf/network_conf.c | 18 src/conf/network_conf.h | 1 + src/conf/schemas/network.rng | 3 + src/libvirt_private.syms | 4 + src/network/bridge_driver.c | 32 ++- src/util/virsocketaddr.c | 63 + src/util/virsocketaddr.h | 4 + src/util/virsystemd.c| 166 +++ src/util/virsystemd.h| 7 ++ src/util/virsystemdpriv.h| 1 + tests/virsystemdtest.c | 147 +++ 13 files changed, 421 insertions(+), 41 deletions(-) -- 2.43.0 ___ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-le...@lists.libvirt.org
[libvirt PATCH] docs: Fix typo in network XML documentation
Signed-off-by: Jiri Denemark --- Pushed as trivial. docs/formatnetwork.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/formatnetwork.rst b/docs/formatnetwork.rst index 809e842487..16e81246fa 100644 --- a/docs/formatnetwork.rst +++ b/docs/formatnetwork.rst @@ -141,7 +141,7 @@ to the physical LAN (if at all). (which will also be managed using firewalld tools). :since:`Since 5.1.0` ``mtu`` - The ``size`` attribute of the ``mtu>`` element specifies the Maximum + The ``size`` attribute of the element specifies the Maximum Transmission Unit (MTU) for the network. :since:`Since 3.1.0` . In the case of a libvirt-managed network (one with forward mode of ``nat``, ``route``, ``open``, or no ``forward`` element (i.e. an isolated network), this will be -- 2.43.0 ___ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-le...@lists.libvirt.org
Re: [PATCH 10/11] nodedev: Implement virNodeDeviceUpdateXML
On 2/1/24 11:07 AM, Boris Fiuczynski wrote: On 1/31/24 22:41, Jonathon Jongsma wrote: On 1/19/24 10:38 AM, Boris Fiuczynski wrote: Implement the API functions in the node device driver by using mdevctl modify with the options defined and live. Increase the minimum mdevctl version to 1.3.0 in spec file to ensure support exists in mdevctl. mdevctl 1.3.0 was only released about 3 weeks ago, so I don't think we can add an unconditional dependency on it. I think we'll have to make sure that we can degrade gracefully when the required version isn't available. What is your suggestion? 1) Adding a mdevctl version check to the runtime code, which in general can cause trouble interpreting the verion number with regard to distro backports. 2) Before really calling modify find out if mdevctl supports it by issuing e.g. "mdevctl modify --live --help". If live is support the RC is 0 if it is not supported the RC is 2. 3) Something else? Hmm, I was thinking that we only needed the 1.3.0 version for the --live and --defined options, but I now realize that we also need the --jsonfile argument from 1.3.0. That makes it a bit harder to degrade gracefully. However, even if 1.3.0 is installed, not all devices will be able to be live-updated. So we need to handle errors in command execution regardless. If the user has an older mdevctl, the command will return an error and the user will be unable to update an mdev via the new API, which is the same behavior as they had before this patch. If the user has a newer mdevctl, it will just work. Maybe that's good enough for now. Jonathon Signed-off-by: Boris Fiuczynski --- libvirt.spec.in | 2 +- src/node_device/node_device_driver.c | 181 ++- src/node_device/node_device_driver.h | 11 ++ src/node_device/node_device_udev.c | 1 + tests/nodedevmdevctldata/mdevctl-modify.argv | 19 ++ tests/nodedevmdevctltest.c | 64 +++ 6 files changed, 275 insertions(+), 3 deletions(-) create mode 100644 tests/nodedevmdevctldata/mdevctl-modify.argv diff --git a/libvirt.spec.in b/libvirt.spec.in index 8413e3c19a..3ed14fa63c 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -613,7 +613,7 @@ Requires: libvirt-libs = %{version}-%{release} # needed for device enumeration Requires: systemd >= 185 # For managing persistent mediated devices -Requires: mdevctl +Requires: mdevctl >= 1.3.0 # for modprobe of pci devices Requires: module-init-tools diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c index d67c95d68d..dd57e9ca5b 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -54,7 +54,7 @@ virNodeDeviceDriverState *driver; VIR_ENUM_IMPL(virMdevctlCommand, MDEVCTL_CMD_LAST, - "start", "stop", "define", "undefine", "create" + "start", "stop", "define", "undefine", "create", "modify" ); @@ -754,6 +754,7 @@ nodeDeviceGetMdevctlCommand(virNodeDeviceDef *def, case MDEVCTL_CMD_START: case MDEVCTL_CMD_DEFINE: case MDEVCTL_CMD_UNDEFINE: + case MDEVCTL_CMD_MODIFY: cmd = virCommandNewArgList(MDEVCTL, subcommand, NULL); break; case MDEVCTL_CMD_LAST: @@ -767,6 +768,7 @@ nodeDeviceGetMdevctlCommand(virNodeDeviceDef *def, switch (cmd_type) { case MDEVCTL_CMD_CREATE: case MDEVCTL_CMD_DEFINE: + case MDEVCTL_CMD_MODIFY: if (!def->caps->data.mdev.parent_addr) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unable to find parent device '%1$s'"), def->parent); @@ -783,7 +785,8 @@ nodeDeviceGetMdevctlCommand(virNodeDeviceDef *def, virCommandAddArgPair(cmd, "--jsonfile", "/dev/stdin"); virCommandSetInputBuffer(cmd, inbuf); - virCommandSetOutputBuffer(cmd, outbuf); + if (outbuf) + virCommandSetOutputBuffer(cmd, outbuf); break; case MDEVCTL_CMD_UNDEFINE: @@ -868,6 +871,61 @@ virMdevctlDefine(virNodeDeviceDef *def, char **uuid) } +/* gets a virCommand object that executes a mdevctl command to modify a + * a device to an updated version + */ +virCommand* +nodeDeviceGetMdevctlModifyCommand(virNodeDeviceDef *def, + bool defined, + bool live, + char **errmsg) +{ + virCommand *cmd = nodeDeviceGetMdevctlCommand(def, + MDEVCTL_CMD_MODIFY, + NULL, errmsg); + + if (!cmd) + return NULL; + + if (defined) + virCommandAddArg(cmd, "--defined"); + + if (live) + virCommandAddArg(cmd, "--live"); + + return cmd; +} + + +static int +virMdevctlModify(virNodeDeviceDef *def, + bool defined, + bool live) +{ + int status; +
Re: [PATCH 10/11] nodedev: Implement virNodeDeviceUpdateXML
On 1/31/24 22:41, Jonathon Jongsma wrote: On 1/19/24 10:38 AM, Boris Fiuczynski wrote: Implement the API functions in the node device driver by using mdevctl modify with the options defined and live. Increase the minimum mdevctl version to 1.3.0 in spec file to ensure support exists in mdevctl. mdevctl 1.3.0 was only released about 3 weeks ago, so I don't think we can add an unconditional dependency on it. I think we'll have to make sure that we can degrade gracefully when the required version isn't available. What is your suggestion? 1) Adding a mdevctl version check to the runtime code, which in general can cause trouble interpreting the verion number with regard to distro backports. 2) Before really calling modify find out if mdevctl supports it by issuing e.g. "mdevctl modify --live --help". If live is support the RC is 0 if it is not supported the RC is 2. 3) Something else? Signed-off-by: Boris Fiuczynski --- libvirt.spec.in | 2 +- src/node_device/node_device_driver.c | 181 ++- src/node_device/node_device_driver.h | 11 ++ src/node_device/node_device_udev.c | 1 + tests/nodedevmdevctldata/mdevctl-modify.argv | 19 ++ tests/nodedevmdevctltest.c | 64 +++ 6 files changed, 275 insertions(+), 3 deletions(-) create mode 100644 tests/nodedevmdevctldata/mdevctl-modify.argv diff --git a/libvirt.spec.in b/libvirt.spec.in index 8413e3c19a..3ed14fa63c 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -613,7 +613,7 @@ Requires: libvirt-libs = %{version}-%{release} # needed for device enumeration Requires: systemd >= 185 # For managing persistent mediated devices -Requires: mdevctl +Requires: mdevctl >= 1.3.0 # for modprobe of pci devices Requires: module-init-tools diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c index d67c95d68d..dd57e9ca5b 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -54,7 +54,7 @@ virNodeDeviceDriverState *driver; VIR_ENUM_IMPL(virMdevctlCommand, MDEVCTL_CMD_LAST, - "start", "stop", "define", "undefine", "create" + "start", "stop", "define", "undefine", "create", "modify" ); @@ -754,6 +754,7 @@ nodeDeviceGetMdevctlCommand(virNodeDeviceDef *def, case MDEVCTL_CMD_START: case MDEVCTL_CMD_DEFINE: case MDEVCTL_CMD_UNDEFINE: + case MDEVCTL_CMD_MODIFY: cmd = virCommandNewArgList(MDEVCTL, subcommand, NULL); break; case MDEVCTL_CMD_LAST: @@ -767,6 +768,7 @@ nodeDeviceGetMdevctlCommand(virNodeDeviceDef *def, switch (cmd_type) { case MDEVCTL_CMD_CREATE: case MDEVCTL_CMD_DEFINE: + case MDEVCTL_CMD_MODIFY: if (!def->caps->data.mdev.parent_addr) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unable to find parent device '%1$s'"), def->parent); @@ -783,7 +785,8 @@ nodeDeviceGetMdevctlCommand(virNodeDeviceDef *def, virCommandAddArgPair(cmd, "--jsonfile", "/dev/stdin"); virCommandSetInputBuffer(cmd, inbuf); - virCommandSetOutputBuffer(cmd, outbuf); + if (outbuf) + virCommandSetOutputBuffer(cmd, outbuf); break; case MDEVCTL_CMD_UNDEFINE: @@ -868,6 +871,61 @@ virMdevctlDefine(virNodeDeviceDef *def, char **uuid) } +/* gets a virCommand object that executes a mdevctl command to modify a + * a device to an updated version + */ +virCommand* +nodeDeviceGetMdevctlModifyCommand(virNodeDeviceDef *def, + bool defined, + bool live, + char **errmsg) +{ + virCommand *cmd = nodeDeviceGetMdevctlCommand(def, + MDEVCTL_CMD_MODIFY, + NULL, errmsg); + + if (!cmd) + return NULL; + + if (defined) + virCommandAddArg(cmd, "--defined"); + + if (live) + virCommandAddArg(cmd, "--live"); + + return cmd; +} + + +static int +virMdevctlModify(virNodeDeviceDef *def, + bool defined, + bool live) +{ + int status; + g_autofree char *errmsg = NULL; + g_autoptr(virCommand) cmd = nodeDeviceGetMdevctlModifyCommand(def, + defined, + live, + ); + + if (!cmd) + return -1; + + if (virCommandRun(cmd, ) < 0) + return -1; + + if (status != 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to modify mediated device: %1$s"), + MDEVCTL_ERROR(errmsg)); + return -1; + } + + return 0; +} + + static virNodeDevicePtr
Re: [PATCH 05/11] tools: add option inactive to nodedev-dumpxml
On 2/1/24 17:39, Jonathon Jongsma wrote: @@ -608,7 +613,15 @@ cmdNodeDeviceDumpXML(vshControl *ctl, const vshCmd *cmd) if (!device) return false; - if (!(xml = virNodeDeviceGetXMLDesc(device, 0))) + if (vshCommandOptBool(cmd, "inactive")) { + flags |= VIR_NODE_DEVICE_GET_XML_DESC_INACTIVE; + if (!virNodeDeviceIsPersistent(device)) { + vshError(ctl, _("Node device '%1$s' is not persistent"), device_value); + return false; + } I believe you've already handled this within virNodeDeviceGetXMLDesc() in patch 4. There shouldn't be any need to duplicate that check here. Without the check in the client the error message looks like this: # virsh nodedev-dumpxml --inactive mdev_c60cc60c_c60c_c60c_c60c_c60cc60cc60c_0_0_0008 error: Requested operation is not valid: node device 'mdev_c60cc60c_c60c_c60c_c60c_c60cc60cc60c_0_0_0008' is not persistent I added the additional check in the virsh client to create a user friendlier message looking like this: # virsh nodedev-dumpxml --inactive mdev_c60cc60c_c60c_c60c_c60c_c60cc60cc60c_0_0_0008 error: Node device 'mdev_c60cc60c_c60c_c60c_c60c_c60cc60cc60c_0_0_0008' is not persistent Do you want it removed? I think the first error message is fine, and it's more maintainable to not keep the precondition checks within the function itself. Ok, I removed the precheck. -- Mit freundlichen Grüßen/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Wolfgang Wendt Geschäftsführung: David Faller Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294 ___ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-le...@lists.libvirt.org
Re: [PATCH 04/11] nodedev: add an active config to mdev
On 2/1/24 17:16, Jonathon Jongsma wrote: +/** + * virNodeDeviceGetXMLDescFlags: + * + * Flags used to provide the state of the returned node device configuration. + * + * Since: 10.1.0 + */ +typedef enum { + VIR_NODE_DEVICE_GET_XML_DESC_INACTIVE = 1 << 0, /* dump inactive device configuration (Since: 10.1.0) */ +} virNodeDeviceGetXMLDescFlags; In all of the other similar cases, this type is named vir$(OBJECT)XMLFlags and the flag itself is named VIR_$(OBJECT)_XML_INACTIVE. So for consistency, I'd remove the 'get' and the 'desc' from the names. I disagree as all other methods that make use of flags base the flags names on the method name. Here are the examples: virNodeDeviceCreateXML virNodeDeviceCreateXMLFlags vir Node Device Create XML VIR_NODE_DEVICE_CREATE_XML_* virNodeDeviceDefineXML virNodeDeviceDefineXMLFlags vir Node Device Define XML VIR_NODE_DEVICE_DEFINE_XML_* virConnectListAllNodeDevices virConnectListAllNodeDeviceFlags vir Connect List Node Device [All is removed] VIR_CONNECT_LIST_NODE_DEVICES_* These are the reasons I chose for consistency: virNodeDeviceGetXMLDesc virNodeDeviceGetXMLDescFlags vir Node Device Get XML Desc VIR_NODE_DEVICE_GET_XML_DESC_INACTIVE That's true in general, however for the *GetXMLDesc() functions, this pattern doesn't hold: domain: - virDomainGetXMLDesc() - virDomainXMLFlags - VIR_DOMAIN_XML_INACTIVE storage: - virStoragePoolGetXMLDesc() - virStorageXMLFlags - VIR_STORAGE_XML_INACTIVE network: - virNetworkGetXMLDesc() - virNetworkXMLFlags - VIR_NETWORK_XML_INACTIVE interface: - virInterfaceGetXMLDesc() - virInterfaceXMLFlags - VIR_INTERFACE_XML_INACTIVE There are no types following the *GetXMLDescFlags pattern: $ git grep XMLDescFlags include/ $ I don't feel personally strongly about this point because there are consistency arguments for both approaches. But I thought I'd mention it. Jonathon Ok, following the cross driver pattern seems reasonable. I will change it to prevent a deviation from the exceptional GetXMLDesc pattern. :D -- Mit freundlichen Grüßen/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Wolfgang Wendt Geschäftsführung: David Faller Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294 ___ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-le...@lists.libvirt.org
Re: [PATCH 05/11] tools: add option inactive to nodedev-dumpxml
On 2/1/24 8:35 AM, Boris Fiuczynski wrote: On 1/31/24 22:34, Jonathon Jongsma wrote: On 1/19/24 10:38 AM, Boris Fiuczynski wrote: Allow to dump the XML of the persisted mdev when the mdev has been started instead of the current state only. Signed-off-by: Boris Fiuczynski --- docs/manpages/virsh.rst | 7 +-- tools/virsh-nodedev.c | 15 ++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index ed1027e133..3a814dccd2 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -5422,14 +5422,17 @@ nodedev-dumpxml :: - nodedev-dumpxml [--xpath EXPRESSION] [--wrap] device + nodedev-dumpxml [--inactive] [--xpath EXPRESSION] [--wrap] device Dump a XML representation for the given node device, including such information as the device name, which bus owns the device, the vendor and product id, and any capabilities of the device usable by libvirt (such as whether device reset is supported). *device* can be either device name or wwn pair in "wwnn,wwpn" format (only works -for HBA). +for HBA). An additional option affecting the XML dump may be +used. *--inactive* tells virsh to dump the node device configuration +that will be used on next start of the node device as opposed to the +current node device configuration. If the **--xpath** argument provides an XPath expression, it will be evaluated against the output XML and only those matching nodes will diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index fb38fd7fcc..54e192d619 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -575,6 +575,10 @@ static const vshCmdOptDef opts_node_device_dumpxml[] = { .help = N_("device name or wwn pair in 'wwnn,wwpn' format"), .completer = virshNodeDeviceNameCompleter, }, + {.name = "inactive", + .type = VSH_OT_BOOL, + .help = N_("show inactive defined XML"), + }, {.name = "xpath", .type = VSH_OT_STRING, .flags = VSH_OFLAG_REQ_OPT, @@ -594,6 +598,7 @@ cmdNodeDeviceDumpXML(vshControl *ctl, const vshCmd *cmd) g_autoptr(virshNodeDevice) device = NULL; g_autofree char *xml = NULL; const char *device_value = NULL; + unsigned int flags = 0; bool wrap = vshCommandOptBool(cmd, "wrap"); const char *xpath = NULL; @@ -608,7 +613,15 @@ cmdNodeDeviceDumpXML(vshControl *ctl, const vshCmd *cmd) if (!device) return false; - if (!(xml = virNodeDeviceGetXMLDesc(device, 0))) + if (vshCommandOptBool(cmd, "inactive")) { + flags |= VIR_NODE_DEVICE_GET_XML_DESC_INACTIVE; + if (!virNodeDeviceIsPersistent(device)) { + vshError(ctl, _("Node device '%1$s' is not persistent"), device_value); + return false; + } I believe you've already handled this within virNodeDeviceGetXMLDesc() in patch 4. There shouldn't be any need to duplicate that check here. Without the check in the client the error message looks like this: # virsh nodedev-dumpxml --inactive mdev_c60cc60c_c60c_c60c_c60c_c60cc60cc60c_0_0_0008 error: Requested operation is not valid: node device 'mdev_c60cc60c_c60c_c60c_c60c_c60cc60cc60c_0_0_0008' is not persistent I added the additional check in the virsh client to create a user friendlier message looking like this: # virsh nodedev-dumpxml --inactive mdev_c60cc60c_c60c_c60c_c60c_c60cc60cc60c_0_0_0008 error: Node device 'mdev_c60cc60c_c60c_c60c_c60c_c60cc60cc60c_0_0_0008' is not persistent Do you want it removed? I think the first error message is fine, and it's more maintainable to not keep the precondition checks within the function itself. + } + + if (!(xml = virNodeDeviceGetXMLDesc(device, flags))) return false; return virshDumpXML(ctl, xml, "node-device", xpath, wrap); Reviewed-by: Jonathon Jongsma Thanks ___ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-le...@lists.libvirt.org ___ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-le...@lists.libvirt.org
Re: [PATCH] virt-admin: Add warning when connection to default daemon fails
On 2/1/24 9:35 AM, Peter Krempa wrote: The admin connection defaults to the system-wide 'libvirtd' daemon to manage (libvirtd:///system). As we've now switched to modular daemons this will not work for most users out of the box: $ virt-admin version error: Failed to connect to the admin server error: no valid connection error: Failed to connect socket to '/run/user/1000/libvirt/libvirt-admin-sock': No such file or directory As we don't want to assume which daemon the user wants to manage in the modular topology there's no reasonable default to pick. Give a hint to the users to use the '-c' if the connection to the default URI fails: $ virt-admin version NOTE: Connecting to default daemon. Specify daemon using '-c' (e.g. virtqemud:///system) error: Failed to connect to the admin server error: no valid connection error: Failed to connect socket to '/run/user/1000/libvirt/libvirt-admin-sock': No such file or directory Signed-off-by: Peter Krempa --- tools/virt-admin.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/virt-admin.c b/tools/virt-admin.c index fa9304c772..aaf6edb9a9 100644 --- a/tools/virt-admin.c +++ b/tools/virt-admin.c @@ -102,6 +102,9 @@ vshAdmConnect(vshControl *ctl, unsigned int flags) priv->conn = virAdmConnectOpen(ctl->connname, flags); if (!priv->conn) { +if (!ctl->connname) +vshPrintExtra(ctl, "%s", _("NOTE: Connecting to default daemon. Specify daemon using '-c' (e.g. virtqemud:///system)\n")); + if (priv->wantReconnect) vshError(ctl, "%s", _("Failed to reconnect to the admin server")); else Reviewed-by: Jonathon Jongsma ___ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-le...@lists.libvirt.org
Re: [PATCH 04/11] nodedev: add an active config to mdev
On 2/1/24 6:17 AM, Boris Fiuczynski wrote: On 1/31/24 22:30, Jonathon Jongsma wrote: On 1/19/24 10:38 AM, Boris Fiuczynski wrote: The configuration of a defined mdev can be modified after the mdev is started. The defined configuration and the active configuration can therefore run out of sync. Handle this by storing the modifiable data which is the mdev type and attributes in two separate active and defined configurations. mdevctl supports with callout scripts to do an attribute retrieval of started mdevs which is already implemented in libvirt. Signed-off-by: Boris Fiuczynski --- include/libvirt/libvirt-nodedev.h | 11 src/conf/node_device_conf.c | 53 ++-- src/conf/node_device_conf.h | 5 +- src/libvirt-nodedev.c | 2 +- src/node_device/node_device_driver.c | 61 +-- src/node_device/node_device_driver.h | 6 +- src/node_device/node_device_udev.c | 4 +- src/test/test_driver.c | 6 +- tests/nodedevmdevctltest.c | 4 +- ...v_c60cc60c_c60c_c60c_c60c_c60cc60cc60c.xml | 14 + ...d_b7f0_4fea_b468_f1da537d301b_inactive.xml | 1 + ...v_c60cc60c_c60c_c60c_c60c_c60cc60cc60c.xml | 10 +++ ...c_c60c_c60c_c60c_c60cc60cc60c_inactive.xml | 9 +++ ...9_36ea_4111_8f0a_8c9a70e21366_inactive.xml | 1 + ...9_495e_4243_ad9f_beb3f14c23d9_inactive.xml | 1 + ...4_f554_4dc1_809d_b2a01e8e48ad_inactive.xml | 8 +++ ...6_1ca8_49ac_b176_871d16c13076_inactive.xml | 1 + tests/nodedevxml2xmltest.c | 59 +++--- 18 files changed, 197 insertions(+), 59 deletions(-) create mode 100644 tests/nodedevschemadata/mdev_c60cc60c_c60c_c60c_c60c_c60cc60cc60c.xml create mode 12 tests/nodedevxml2xmlout/mdev_3627463d_b7f0_4fea_b468_f1da537d301b_inactive.xml create mode 100644 tests/nodedevxml2xmlout/mdev_c60cc60c_c60c_c60c_c60c_c60cc60cc60c.xml create mode 100644 tests/nodedevxml2xmlout/mdev_c60cc60c_c60c_c60c_c60c_c60cc60cc60c_inactive.xml create mode 12 tests/nodedevxml2xmlout/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366_inactive.xml create mode 12 tests/nodedevxml2xmlout/mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9_inactive.xml create mode 100644 tests/nodedevxml2xmlout/mdev_ee0b88c4_f554_4dc1_809d_b2a01e8e48ad_inactive.xml create mode 12 tests/nodedevxml2xmlout/mdev_fedc4916_1ca8_49ac_b176_871d16c13076_inactive.xml diff --git a/include/libvirt/libvirt-nodedev.h b/include/libvirt/libvirt-nodedev.h index 428b0d722f..d18246e2f6 100644 --- a/include/libvirt/libvirt-nodedev.h +++ b/include/libvirt/libvirt-nodedev.h @@ -117,6 +117,17 @@ int virNodeDeviceListCaps (virNodeDevicePtr dev, char **const names, int maxnames); +/** + * virNodeDeviceGetXMLDescFlags: + * + * Flags used to provide the state of the returned node device configuration. + * + * Since: 10.1.0 + */ +typedef enum { + VIR_NODE_DEVICE_GET_XML_DESC_INACTIVE = 1 << 0, /* dump inactive device configuration (Since: 10.1.0) */ +} virNodeDeviceGetXMLDescFlags; In all of the other similar cases, this type is named vir$(OBJECT)XMLFlags and the flag itself is named VIR_$(OBJECT)_XML_INACTIVE. So for consistency, I'd remove the 'get' and the 'desc' from the names. I disagree as all other methods that make use of flags base the flags names on the method name. Here are the examples: virNodeDeviceCreateXML virNodeDeviceCreateXMLFlags vir Node Device Create XML VIR_NODE_DEVICE_CREATE_XML_* virNodeDeviceDefineXML virNodeDeviceDefineXMLFlags vir Node Device Define XML VIR_NODE_DEVICE_DEFINE_XML_* virConnectListAllNodeDevices virConnectListAllNodeDeviceFlags vir Connect List Node Device [All is removed] VIR_CONNECT_LIST_NODE_DEVICES_* These are the reasons I chose for consistency: virNodeDeviceGetXMLDesc virNodeDeviceGetXMLDescFlags vir Node Device Get XML Desc VIR_NODE_DEVICE_GET_XML_DESC_INACTIVE That's true in general, however for the *GetXMLDesc() functions, this pattern doesn't hold: domain: - virDomainGetXMLDesc() - virDomainXMLFlags - VIR_DOMAIN_XML_INACTIVE storage: - virStoragePoolGetXMLDesc() - virStorageXMLFlags - VIR_STORAGE_XML_INACTIVE network: - virNetworkGetXMLDesc() - virNetworkXMLFlags - VIR_NETWORK_XML_INACTIVE interface: - virInterfaceGetXMLDesc() - virInterfaceXMLFlags - VIR_INTERFACE_XML_INACTIVE There are no types following the *GetXMLDescFlags pattern: $ git grep XMLDescFlags include/ $ I don't feel personally strongly about this point because there are consistency arguments for both approaches. But I thought I'd mention it. Jonathon + char * virNodeDeviceGetXMLDesc (virNodeDevicePtr dev, unsigned int flags); diff --git
Re: [PATCH v2 0/5] Initial network support in ch driver.
On Tue, Jan 30, 2024 at 06:28:05PM +0100, Michal Pr??vozn??k wrote: > On 1/16/24 22:25, Praveen K Paladugu wrote: > > v2: > > * Refactor virSocketRecvHttpResponse to return responses without parsing > > http > > responses. > > * Use errno to report errors in virsocket.c > > * Address WIN32 build failure in virsocket.c > > * Fix code indentations > > > > Praveen K Paladugu (5): > > conf: Drop unused parameter > > hypervisor: Move domain interface mgmt methods > > util: Add util methods required by ch networking > > ch: Introduce version based cap for network support > > ch: Enable ETHERNET Network mode support > > > > po/POTFILES | 3 + > > src/ch/ch_capabilities.c | 9 + > > src/ch/ch_capabilities.h | 1 + > > src/ch/ch_conf.h | 4 + > > src/ch/ch_domain.c| 41 +++ > > src/ch/ch_domain.h| 3 + > > src/ch/ch_interface.c | 100 +++ > > src/ch/ch_interface.h | 35 +++ > > src/ch/ch_monitor.c | 213 +- > > src/ch/ch_monitor.h | 7 +- > > src/ch/ch_process.c | 166 ++- > > src/ch/meson.build| 2 + > > src/conf/domain_conf.c| 1 - > > src/conf/domain_conf.h| 3 +- > > src/hypervisor/domain_interface.c | 457 ++ > > src/hypervisor/domain_interface.h | 45 +++ > > src/hypervisor/meson.build| 1 + > > src/libvirt_private.syms | 11 + > > src/libxl/libxl_domain.c | 2 +- > > src/libxl/libxl_driver.c | 4 +- > > src/lxc/lxc_driver.c | 2 +- > > src/lxc/lxc_process.c | 4 +- > > src/qemu/qemu_command.c | 8 +- > > src/qemu/qemu_hotplug.c | 15 +- > > src/qemu/qemu_interface.c | 339 +- > > src/qemu/qemu_interface.h | 11 - > > src/qemu/qemu_process.c | 72 + > > src/util/virsocket.c | 116 > > src/util/virsocket.h | 3 + > > 29 files changed, 1107 insertions(+), 571 deletions(-) > > create mode 100644 src/ch/ch_interface.c > > create mode 100644 src/ch/ch_interface.h > > create mode 100644 src/hypervisor/domain_interface.c > > create mode 100644 src/hypervisor/domain_interface.h > > > > Now, this is almost correct. I only have couple of suggestions. No need > to resend another version. I've uploaded these patches among with my > suggestions to my gitlab: > > > https://gitlab.com/MichalPrivoznik/libvirt/-/tree/ch_networking?ref_type=heads > > You'll find 'fixup' commits there - these contains fixes to those small > issues I've raised in my review. I'll squash them in before merging. > > Then, there's one suggestion - "Possible move of virSocketRecv() into > ch_process.c" - honestly, I don't feel like virSocketRecv() belongs into > src/util/ but I can't explain why really. For the time being we can have > it in src/ch/. I'd split this commit and squash its parts into > respective commits. > I don't feel strongly about keep virSocketRecv() in src/util. The method seemed generic enough to keep it in src/util. If you are not comfortable keeping it there, I am fine with moving it to src/ch. > Please do check if code still works even with my fixups and whether you > agree with suggested changes. If so, I can give my reviewed by and merge > these. > Thanks for the detailed review on this patchset. I tested the patchset in above branch and I noticed 2 bugs. One introduced by me in v2, and one introduced by a fixup commit. First bug is fixed by https://github.com/praveen-pk/libvirt/commit/6c3b068957d854c0b4f51925d3e87a88b41803a3. Seems like I missed to test a domain XML without an IP address to guest interface. This patch fixes the bug. Second bug is fixed by https://github.com/praveen-pk/libvirt/commit/a7f7bcefbcc97f755b5075e52233288d12cdcfc4. As `control` is now allocated from heap, the size is incorrectly set in `msg.msg_controllen`. This patch fixes it. I marked both these commits as `fixup2`. With these commits, the patchset looks good. Please go ahead and merge. If you'd like for me to send you a v3 with all the commit properly squashed, I am happy to do that as well. Regards, Praveen > Michal > ___ > Devel mailing list -- devel@lists.libvirt.org > To unsubscribe send an email to devel-le...@lists.libvirt.org ___ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-le...@lists.libvirt.org
[PATCH] virt-admin: Add warning when connection to default daemon fails
The admin connection defaults to the system-wide 'libvirtd' daemon to manage (libvirtd:///system). As we've now switched to modular daemons this will not work for most users out of the box: $ virt-admin version error: Failed to connect to the admin server error: no valid connection error: Failed to connect socket to '/run/user/1000/libvirt/libvirt-admin-sock': No such file or directory As we don't want to assume which daemon the user wants to manage in the modular topology there's no reasonable default to pick. Give a hint to the users to use the '-c' if the connection to the default URI fails: $ virt-admin version NOTE: Connecting to default daemon. Specify daemon using '-c' (e.g. virtqemud:///system) error: Failed to connect to the admin server error: no valid connection error: Failed to connect socket to '/run/user/1000/libvirt/libvirt-admin-sock': No such file or directory Signed-off-by: Peter Krempa --- tools/virt-admin.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/virt-admin.c b/tools/virt-admin.c index fa9304c772..aaf6edb9a9 100644 --- a/tools/virt-admin.c +++ b/tools/virt-admin.c @@ -102,6 +102,9 @@ vshAdmConnect(vshControl *ctl, unsigned int flags) priv->conn = virAdmConnectOpen(ctl->connname, flags); if (!priv->conn) { +if (!ctl->connname) +vshPrintExtra(ctl, "%s", _("NOTE: Connecting to default daemon. Specify daemon using '-c' (e.g. virtqemud:///system)\n")); + if (priv->wantReconnect) vshError(ctl, "%s", _("Failed to reconnect to the admin server")); else -- 2.43.0 ___ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-le...@lists.libvirt.org
Re: [PATCH 07/11] tools: add switches persisted and transient to nodedev-list
On 1/31/24 22:38, Jonathon Jongsma wrote: On 1/19/24 10:38 AM, Boris Fiuczynski wrote: Now that we can filter persisted and transient node devices in virConnectListAllNodeDevices(), add these switches also to the virsh nodedev-list command. Signed-off-by: Boris Fiuczynski --- docs/manpages/virsh.rst | 8 ++-- tools/virsh-nodedev.c | 24 ++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 3a814dccd2..4bcfbc230b 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -5461,7 +5461,7 @@ nodedev-list :: - nodedev-list [--cap capability] [--tree] [--inactive | --all] + nodedev-list [--cap capability] [--tree] [--inactive | --all] [--persisted | --transient] s/persisted/persistent/ List all of the devices available on the node that are known by libvirt. *cap* is used to filter the list by capability types, the types must be @@ -5470,7 +5470,11 @@ separated by comma, e.g. --cap pci,scsi. Valid capability types include 'scsi', 'storage', 'fc_host', 'vports', 'scsi_generic', 'drm', 'mdev', 'mdev_types', 'ccw', 'css', 'ap_card', 'ap_queue', 'ap_matrix'. By default, only active devices are listed. *--inactive* is used to list only inactive -devices, and *-all* is used to list both active and inactive devices. +devices, and *--all* is used to list both active and inactive devices. +*--persisted* is used to list only persisted devices, and *--transient* is here too +used to list only transient devices. Not providing *--persisted* or +*--transient* will list all devices unless filtered otherwise. *--transient* +is mutually exclusive with *--persisted* and *--inactive*. again If *--tree* is used, the output is formatted in a tree representing parents of each node. *--tree* is mutually exclusive with all other options. diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index 54e192d619..4acb955efe 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -390,6 +390,14 @@ static const vshCmdOptDef opts_node_list_devices[] = { .type = VSH_OT_BOOL, .help = N_("list inactive & active devices") }, + {.name = "persisted", again + .type = VSH_OT_BOOL, + .help = N_("list persisted devices") again + }, + {.name = "transient", + .type = VSH_OT_BOOL, + .help = N_("list transient devices") + }, {.name = NULL} }; @@ -407,6 +415,8 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED) int cap_type = -1; bool inactive = vshCommandOptBool(cmd, "inactive"); bool all = vshCommandOptBool(cmd, "all"); + bool persisted = vshCommandOptBool(cmd, "persisted"); again + bool transient = vshCommandOptBool(cmd, "transient"); ignore_value(vshCommandOptStringQuiet(ctl, cmd, "cap", _str)); @@ -420,8 +430,13 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED) return false; } - if (tree && (cap_str || inactive)) { - vshError(ctl, "%s", _("Option --tree is incompatible with --cap and --inactive")); + if (transient && (persisted || inactive)) { + vshError(ctl, "%s", _("Option --transient is incompatible with --persisted and --inactive")); again + return false; + } + + if (tree && (cap_str || inactive || persisted || transient)) { + vshError(ctl, "%s", _("Option --tree is incompatible with --cap, --inactive, --persisted and --transient")); again All changed return false; } @@ -509,6 +524,11 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED) if (!inactive) flags |= VIR_CONNECT_LIST_NODE_DEVICES_ACTIVE; + if (persisted) + flags |= VIR_CONNECT_LIST_NODE_DEVICES_PERSISTED; + if (transient) + flags |= VIR_CONNECT_LIST_NODE_DEVICES_TRANSIENT; + if (!(list = virshNodeDeviceListCollect(ctl, caps, ncaps, flags))) { ret = false; goto cleanup; Reviewed-by: Jonathon Jongsma Thanks ___ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-le...@lists.libvirt.org -- Mit freundlichen Grüßen/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Wolfgang Wendt Geschäftsführung: David Faller Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294 ___ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-le...@lists.libvirt.org
Re: [PATCH 06/11] nodedev: add persisted and transient filter on list
On 1/31/24 22:38, Jonathon Jongsma wrote: On 1/19/24 10:38 AM, Boris Fiuczynski wrote: Allow to filter node devices based on their persisted or transient states. Signed-off-by: Boris Fiuczynski --- include/libvirt/libvirt-nodedev.h | 2 ++ src/conf/node_device_conf.h | 7 ++- src/conf/virnodedeviceobj.c | 8 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/include/libvirt/libvirt-nodedev.h b/include/libvirt/libvirt-nodedev.h index d18246e2f6..dff394ec86 100644 --- a/include/libvirt/libvirt-nodedev.h +++ b/include/libvirt/libvirt-nodedev.h @@ -91,6 +91,8 @@ typedef enum { VIR_CONNECT_LIST_NODE_DEVICES_CAP_AP_MATRIX = 1 << 20, /* s390 AP Matrix (Since: 7.0.0) */ VIR_CONNECT_LIST_NODE_DEVICES_CAP_VPD = 1 << 21, /* Device with VPD (Since: 7.9.0) */ + VIR_CONNECT_LIST_NODE_DEVICES_PERSISTED = 1 << 28, /* Persisted devices (Since: 10.1.0) */ s/PERSISTED/PERSISTENT/ + VIR_CONNECT_LIST_NODE_DEVICES_TRANSIENT = 1 << 29, /* Transient devices (Since: 10.1.0) */ VIR_CONNECT_LIST_NODE_DEVICES_INACTIVE = 1 << 30, /* Inactive devices (Since: 7.3.0) */ VIR_CONNECT_LIST_NODE_DEVICES_ACTIVE = 1U << 31, /* Active devices (Since: 7.3.0) */ } virConnectListAllNodeDeviceFlags; diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h index f59440dbb9..3ee1fbc665 100644 --- a/src/conf/node_device_conf.h +++ b/src/conf/node_device_conf.h @@ -432,9 +432,14 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(virNodeDevCapsDef, virNodeDevCapsDefFree); VIR_CONNECT_LIST_NODE_DEVICES_ACTIVE | \ VIR_CONNECT_LIST_NODE_DEVICES_INACTIVE +#define VIR_CONNECT_LIST_NODE_DEVICES_FILTERS_PERSIST \ s/PERSIST/PERSISTENT/ + VIR_CONNECT_LIST_NODE_DEVICES_PERSISTED | \ s/PERSISTED/PERSISTENT/ All changed + VIR_CONNECT_LIST_NODE_DEVICES_TRANSIENT + #define VIR_CONNECT_LIST_NODE_DEVICES_FILTERS_ALL \ VIR_CONNECT_LIST_NODE_DEVICES_FILTERS_CAP | \ - VIR_CONNECT_LIST_NODE_DEVICES_FILTERS_ACTIVE + VIR_CONNECT_LIST_NODE_DEVICES_FILTERS_ACTIVE | \ + VIR_CONNECT_LIST_NODE_DEVICES_FILTERS_PERSIST int virNodeDeviceGetSCSIHostCaps(virNodeDevCapSCSIHost *scsi_host); diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c index cfef30d47e..0b9ca8c864 100644 --- a/src/conf/virnodedeviceobj.c +++ b/src/conf/virnodedeviceobj.c @@ -911,6 +911,14 @@ virNodeDeviceObjMatch(virNodeDeviceObj *obj, return false; } + if (flags & (VIR_CONNECT_LIST_NODE_DEVICES_FILTERS_PERSIST)) { + if (!((MATCH(VIR_CONNECT_LIST_NODE_DEVICES_PERSISTED) && + virNodeDeviceObjIsPersistent(obj)) || + (MATCH(VIR_CONNECT_LIST_NODE_DEVICES_TRANSIENT) && + !virNodeDeviceObjIsPersistent(obj + return false; + } + return true; } #undef MATCH Reviewed-by: Jonathon Jongsma Thanks ___ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-le...@lists.libvirt.org -- Mit freundlichen Grüßen/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Wolfgang Wendt Geschäftsführung: David Faller Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294 ___ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-le...@lists.libvirt.org
Re: [PATCH 05/11] tools: add option inactive to nodedev-dumpxml
On 1/31/24 22:34, Jonathon Jongsma wrote: On 1/19/24 10:38 AM, Boris Fiuczynski wrote: Allow to dump the XML of the persisted mdev when the mdev has been started instead of the current state only. Signed-off-by: Boris Fiuczynski --- docs/manpages/virsh.rst | 7 +-- tools/virsh-nodedev.c | 15 ++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index ed1027e133..3a814dccd2 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -5422,14 +5422,17 @@ nodedev-dumpxml :: - nodedev-dumpxml [--xpath EXPRESSION] [--wrap] device + nodedev-dumpxml [--inactive] [--xpath EXPRESSION] [--wrap] device Dump a XML representation for the given node device, including such information as the device name, which bus owns the device, the vendor and product id, and any capabilities of the device usable by libvirt (such as whether device reset is supported). *device* can be either device name or wwn pair in "wwnn,wwpn" format (only works -for HBA). +for HBA). An additional option affecting the XML dump may be +used. *--inactive* tells virsh to dump the node device configuration +that will be used on next start of the node device as opposed to the +current node device configuration. If the **--xpath** argument provides an XPath expression, it will be evaluated against the output XML and only those matching nodes will diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index fb38fd7fcc..54e192d619 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -575,6 +575,10 @@ static const vshCmdOptDef opts_node_device_dumpxml[] = { .help = N_("device name or wwn pair in 'wwnn,wwpn' format"), .completer = virshNodeDeviceNameCompleter, }, + {.name = "inactive", + .type = VSH_OT_BOOL, + .help = N_("show inactive defined XML"), + }, {.name = "xpath", .type = VSH_OT_STRING, .flags = VSH_OFLAG_REQ_OPT, @@ -594,6 +598,7 @@ cmdNodeDeviceDumpXML(vshControl *ctl, const vshCmd *cmd) g_autoptr(virshNodeDevice) device = NULL; g_autofree char *xml = NULL; const char *device_value = NULL; + unsigned int flags = 0; bool wrap = vshCommandOptBool(cmd, "wrap"); const char *xpath = NULL; @@ -608,7 +613,15 @@ cmdNodeDeviceDumpXML(vshControl *ctl, const vshCmd *cmd) if (!device) return false; - if (!(xml = virNodeDeviceGetXMLDesc(device, 0))) + if (vshCommandOptBool(cmd, "inactive")) { + flags |= VIR_NODE_DEVICE_GET_XML_DESC_INACTIVE; + if (!virNodeDeviceIsPersistent(device)) { + vshError(ctl, _("Node device '%1$s' is not persistent"), device_value); + return false; + } I believe you've already handled this within virNodeDeviceGetXMLDesc() in patch 4. There shouldn't be any need to duplicate that check here. Without the check in the client the error message looks like this: # virsh nodedev-dumpxml --inactive mdev_c60cc60c_c60c_c60c_c60c_c60cc60cc60c_0_0_0008 error: Requested operation is not valid: node device 'mdev_c60cc60c_c60c_c60c_c60c_c60cc60cc60c_0_0_0008' is not persistent I added the additional check in the virsh client to create a user friendlier message looking like this: # virsh nodedev-dumpxml --inactive mdev_c60cc60c_c60c_c60c_c60c_c60cc60cc60c_0_0_0008 error: Node device 'mdev_c60cc60c_c60c_c60c_c60c_c60cc60cc60c_0_0_0008' is not persistent Do you want it removed? + } + + if (!(xml = virNodeDeviceGetXMLDesc(device, flags))) return false; return virshDumpXML(ctl, xml, "node-device", xpath, wrap); Reviewed-by: Jonathon Jongsma Thanks ___ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-le...@lists.libvirt.org -- Mit freundlichen Grüßen/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Wolfgang Wendt Geschäftsführung: David Faller Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294 ___ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-le...@lists.libvirt.org
Re: [PATCH 4/5] Revert "hw/elf_ops: Ignore loadable segments with zero size"
On Thu, 1 Feb 2024 at 12:30, Alex Bennée wrote: > > This regressed qemu-system-xtensa: > > TESTtest_load_store on xtensa > qemu-system-xtensa: Some ROM regions are overlapping > These ROM regions might have been loaded by direct user request or by > default. > They could be BIOS/firmware images, a guest kernel, initrd or some other > file loaded into guest memory. > Check whether you intended to load all this guest code, and whether it has > been built to load to the correct addresses. > > The following two regions overlap (in the memory address space): > test_load_store ELF program header segment 1 (addresses > 0x1000 - 0x1f26) > test_load_store ELF program header segment 2 (addresses > 0x1ab8 - 0x1ab8) Hmm -- this second segment is zero length, so why did we create a ROM blob for it? The commit being reverted here looks like it ought to be expanding the set of things for which we say "zero size, ignore entirely"... Anyway, revert given we have a regression is the first thing to do if there's not an immediately obvious fix. -- PMM ___ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-le...@lists.libvirt.org
Re: [PATCH 0/4] qemu: Stop adding 'raw' -blockdev layer unless necessary
On a Thursday in 2024, Peter Krempa wrote: Peter Krempa (4): tests: qemucapabilitiesdata: Update 'caps_9.0.0_x86_64.replies' qemu: capabilities: Introduce QEMU_CAPS_BLOCKJOB_BACKING_MASK_PROTOCOL qemu: monitor: Use 'backing-mask-protocol' for blockjobs when available qemuBlockStorageSourceNeedsFormatLayer: Stop formatting 'raw' driver when not needed Reviewed-by: Ján Tomko Jano signature.asc Description: PGP signature ___ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-le...@lists.libvirt.org
Re: [PATCH 2/5] docs: mark CRIS support as deprecated
On 01/02/2024 13.28, Alex Bennée wrote: This might be premature but while streamling the avocado tests I s/streamling/streamlining/ ? realised the only tests we have are "check-tcg" ones. The aging fedora-criss-cross image works well enough for developers but can't be s/criss/cris/ used in CI as we need supported build platforms to build QEMU. Does this mean the writing is on the wall for this architecture? Signed-off-by: Alex Bennée Cc: Rabin Vincent Cc: Edgar E. Iglesias Message-Id: <20230925144854.1872513-5-alex.ben...@linaro.org> --- docs/about/deprecated.rst | 8 1 file changed, 8 insertions(+) diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index d4492b94604..82922476d72 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -183,6 +183,14 @@ Nios II CPU (since 8.2) The Nios II architecture is orphan. The ``nios2`` guest CPU support is deprecated and will be removed in a future version of QEMU. +CRIS CPU architecture (since 9.0) +' + +The CRIS architecture was pulled from Linux in 4.17 and the compiler +is no longer packaged in any distro making it harder to run the +``check-tcg`` tests. Unless we can improve the testing situation there +is a chance the code will bitrot without anyone noticing. With the typos fixed: Reviewed-by: Thomas Huth ___ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-le...@lists.libvirt.org
Re: [PATCH 5/5] kconfig: use "select" to enable semihosting
On 01/02/2024 13.28, Alex Bennée wrote: From: Paolo Bonzini Just like all other dependencies, these can be expressed in Kconfig files rather than in the default configurations. Signed-off-by: Paolo Bonzini Acked-by: Alistair Francis Message-Id: <20240129115809.1039924-1-pbonz...@redhat.com> Signed-off-by: Alex Bennée --- configs/devices/m68k-softmmu/default.mak| 2 -- configs/devices/mips-softmmu/common.mak | 3 --- configs/devices/nios2-softmmu/default.mak | 2 -- configs/devices/riscv32-softmmu/default.mak | 2 -- configs/devices/riscv64-softmmu/default.mak | 2 -- configs/devices/xtensa-softmmu/default.mak | 2 -- target/m68k/Kconfig | 1 + target/mips/Kconfig | 1 + target/nios2/Kconfig| 1 + target/riscv/Kconfig| 2 ++ target/xtensa/Kconfig | 1 + 11 files changed, 6 insertions(+), 13 deletions(-) Reviewed-by: Thomas Huth ___ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-le...@lists.libvirt.org
[PATCH 5/5] kconfig: use "select" to enable semihosting
From: Paolo Bonzini Just like all other dependencies, these can be expressed in Kconfig files rather than in the default configurations. Signed-off-by: Paolo Bonzini Acked-by: Alistair Francis Message-Id: <20240129115809.1039924-1-pbonz...@redhat.com> Signed-off-by: Alex Bennée --- configs/devices/m68k-softmmu/default.mak| 2 -- configs/devices/mips-softmmu/common.mak | 3 --- configs/devices/nios2-softmmu/default.mak | 2 -- configs/devices/riscv32-softmmu/default.mak | 2 -- configs/devices/riscv64-softmmu/default.mak | 2 -- configs/devices/xtensa-softmmu/default.mak | 2 -- target/m68k/Kconfig | 1 + target/mips/Kconfig | 1 + target/nios2/Kconfig| 1 + target/riscv/Kconfig| 2 ++ target/xtensa/Kconfig | 1 + 11 files changed, 6 insertions(+), 13 deletions(-) diff --git a/configs/devices/m68k-softmmu/default.mak b/configs/devices/m68k-softmmu/default.mak index 7f8619e4278..8dcaa28ed38 100644 --- a/configs/devices/m68k-softmmu/default.mak +++ b/configs/devices/m68k-softmmu/default.mak @@ -1,7 +1,5 @@ # Default configuration for m68k-softmmu -CONFIG_SEMIHOSTING=y - # Boards: # CONFIG_AN5206=y diff --git a/configs/devices/mips-softmmu/common.mak b/configs/devices/mips-softmmu/common.mak index 7da99327a77..1a853841b27 100644 --- a/configs/devices/mips-softmmu/common.mak +++ b/configs/devices/mips-softmmu/common.mak @@ -1,8 +1,5 @@ # Common mips*-softmmu CONFIG defines -# CONFIG_SEMIHOSTING is always required on this architecture -CONFIG_SEMIHOSTING=y - CONFIG_ISA_BUS=y CONFIG_PCI=y CONFIG_PCI_DEVICES=y diff --git a/configs/devices/nios2-softmmu/default.mak b/configs/devices/nios2-softmmu/default.mak index 1bc4082ea99..e130d024e62 100644 --- a/configs/devices/nios2-softmmu/default.mak +++ b/configs/devices/nios2-softmmu/default.mak @@ -1,7 +1,5 @@ # Default configuration for nios2-softmmu -CONFIG_SEMIHOSTING=y - # Boards: # CONFIG_NIOS2_10M50=y diff --git a/configs/devices/riscv32-softmmu/default.mak b/configs/devices/riscv32-softmmu/default.mak index d847bd5692e..94a236c9c25 100644 --- a/configs/devices/riscv32-softmmu/default.mak +++ b/configs/devices/riscv32-softmmu/default.mak @@ -3,8 +3,6 @@ # Uncomment the following lines to disable these optional devices: # #CONFIG_PCI_DEVICES=n -CONFIG_SEMIHOSTING=y -CONFIG_ARM_COMPATIBLE_SEMIHOSTING=y # Boards: # diff --git a/configs/devices/riscv64-softmmu/default.mak b/configs/devices/riscv64-softmmu/default.mak index bc69301fa4a..3f680594484 100644 --- a/configs/devices/riscv64-softmmu/default.mak +++ b/configs/devices/riscv64-softmmu/default.mak @@ -3,8 +3,6 @@ # Uncomment the following lines to disable these optional devices: # #CONFIG_PCI_DEVICES=n -CONFIG_SEMIHOSTING=y -CONFIG_ARM_COMPATIBLE_SEMIHOSTING=y # Boards: # diff --git a/configs/devices/xtensa-softmmu/default.mak b/configs/devices/xtensa-softmmu/default.mak index 4fe1bf00c94..49e4c9da88c 100644 --- a/configs/devices/xtensa-softmmu/default.mak +++ b/configs/devices/xtensa-softmmu/default.mak @@ -1,7 +1,5 @@ # Default configuration for Xtensa -CONFIG_SEMIHOSTING=y - # Boards: # CONFIG_XTENSA_SIM=y diff --git a/target/m68k/Kconfig b/target/m68k/Kconfig index 23debad519a..9eae71486ff 100644 --- a/target/m68k/Kconfig +++ b/target/m68k/Kconfig @@ -1,2 +1,3 @@ config M68K bool +select SEMIHOSTING diff --git a/target/mips/Kconfig b/target/mips/Kconfig index 6adf1453548..eb19c94c7d4 100644 --- a/target/mips/Kconfig +++ b/target/mips/Kconfig @@ -1,5 +1,6 @@ config MIPS bool +select SEMIHOSTING config MIPS64 bool diff --git a/target/nios2/Kconfig b/target/nios2/Kconfig index 1529ab8950d..c65550c861a 100644 --- a/target/nios2/Kconfig +++ b/target/nios2/Kconfig @@ -1,2 +1,3 @@ config NIOS2 bool +select SEMIHOSTING diff --git a/target/riscv/Kconfig b/target/riscv/Kconfig index b9e5932f13f..adb7de3f37d 100644 --- a/target/riscv/Kconfig +++ b/target/riscv/Kconfig @@ -1,5 +1,7 @@ config RISCV32 bool +select ARM_COMPATIBLE_SEMIHOSTING # for do_common_semihosting() config RISCV64 bool +select ARM_COMPATIBLE_SEMIHOSTING # for do_common_semihosting() diff --git a/target/xtensa/Kconfig b/target/xtensa/Kconfig index a3c8dc7f6d7..5e46049262d 100644 --- a/target/xtensa/Kconfig +++ b/target/xtensa/Kconfig @@ -1,2 +1,3 @@ config XTENSA bool +select SEMIHOSTING -- 2.39.2 ___ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-le...@lists.libvirt.org
[PATCH 4/5] Revert "hw/elf_ops: Ignore loadable segments with zero size"
This regressed qemu-system-xtensa: TESTtest_load_store on xtensa qemu-system-xtensa: Some ROM regions are overlapping These ROM regions might have been loaded by direct user request or by default. They could be BIOS/firmware images, a guest kernel, initrd or some other file loaded into guest memory. Check whether you intended to load all this guest code, and whether it has been built to load to the correct addresses. The following two regions overlap (in the memory address space): test_load_store ELF program header segment 1 (addresses 0x1000 - 0x1f26) test_load_store ELF program header segment 2 (addresses 0x1ab8 - 0x1ab8) make[1]: *** [Makefile:187: run-test_load_store] Error 1 This reverts commit 62570f1434160d356311e1c217537e24a4ac85cd. Signed-off-by: Alex Bennée --- include/hw/elf_ops.h | 75 +--- 1 file changed, 36 insertions(+), 39 deletions(-) diff --git a/include/hw/elf_ops.h b/include/hw/elf_ops.h index 3e966ddd5a1..9c35d1b9da6 100644 --- a/include/hw/elf_ops.h +++ b/include/hw/elf_ops.h @@ -427,16 +427,6 @@ static ssize_t glue(load_elf, SZ)(const char *name, int fd, file_size = ph->p_filesz; /* Size of the allocated data */ data_offset = ph->p_offset; /* Offset where the data is located */ -/* - * Some ELF files really do have segments of zero size; - * just ignore them rather than trying to set the wrong addr, - * or create empty ROM blobs, because the zero-length blob can - * falsely trigger the overlapping-ROM-blobs check. - */ -if (mem_size == 0) { -continue; -} - if (file_size > 0) { if (g_mapped_file_get_length(mapped_file) < file_size + data_offset) { @@ -540,38 +530,45 @@ static ssize_t glue(load_elf, SZ)(const char *name, int fd, *pentry = ehdr.e_entry - ph->p_vaddr + ph->p_paddr; } -if (load_rom) { -g_autofree char *label = -g_strdup_printf("%s ELF program header segment %d", -name, i); - -/* - * rom_add_elf_program() takes its own reference to - * 'mapped_file'. - */ -rom_add_elf_program(label, mapped_file, data, file_size, -mem_size, addr, as); -} else { -MemTxResult res; - -res = address_space_write(as ? as : _space_memory, - addr, MEMTXATTRS_UNSPECIFIED, - data, file_size); -if (res != MEMTX_OK) { -goto fail; -} -/* - * We need to zero'ify the space that is not copied - * from file - */ -if (file_size < mem_size) { -res = address_space_set(as ? as : _space_memory, -addr + file_size, 0, -mem_size - file_size, -MEMTXATTRS_UNSPECIFIED); +/* Some ELF files really do have segments of zero size; + * just ignore them rather than trying to create empty + * ROM blobs, because the zero-length blob can falsely + * trigger the overlapping-ROM-blobs check. + */ +if (mem_size != 0) { +if (load_rom) { +g_autofree char *label = +g_strdup_printf("%s ELF program header segment %d", +name, i); + +/* + * rom_add_elf_program() takes its own reference to + * 'mapped_file'. + */ +rom_add_elf_program(label, mapped_file, data, file_size, +mem_size, addr, as); +} else { +MemTxResult res; + +res = address_space_write(as ? as : _space_memory, + addr, MEMTXATTRS_UNSPECIFIED, + data, file_size); if (res != MEMTX_OK) { goto fail; } +/* + * We need to zero'ify the space that is not copied + * from file + */ +if (file_size < mem_size) { +res = address_space_set(as ? as : _space_memory, +addr + file_size, 0, +mem_size - file_size, +
[PATCH 1/5] tests/docker: Add sqlite3 module to openSUSE Leap container
From: Fabiano Rosas Avocado needs sqlite3: Failed to load plugin from module "avocado.plugins.journal": ImportError("Module 'sqlite3' is not installed. Use: sudo zypper install python311 to install it") >From 'zypper info python311': "This package supplies rich command line features provided by readline, and sqlite3 support for the interpreter core, thus forming a so called "extended" runtime." Include the appropriate package in the lcitool mappings which will guarantee the dockerfile gets properly updated when lcitool is run. Also include the updated dockerfile. Signed-off-by: Fabiano Rosas Suggested-by: Andrea Bolognani Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20240117164227.32143-1-faro...@suse.de> Signed-off-by: Alex Bennée --- tests/docker/dockerfiles/opensuse-leap.docker | 1 + tests/lcitool/mappings.yml| 4 tests/lcitool/projects/qemu.yml | 1 + 3 files changed, 6 insertions(+) diff --git a/tests/docker/dockerfiles/opensuse-leap.docker b/tests/docker/dockerfiles/opensuse-leap.docker index dc0e36ce488..cf753383a45 100644 --- a/tests/docker/dockerfiles/opensuse-leap.docker +++ b/tests/docker/dockerfiles/opensuse-leap.docker @@ -90,6 +90,7 @@ RUN zypper update -y && \ pcre-devel-static \ pipewire-devel \ pkgconfig \ + python311 \ python311-base \ python311-pip \ python311-setuptools \ diff --git a/tests/lcitool/mappings.yml b/tests/lcitool/mappings.yml index 0b908882f1d..407c03301bf 100644 --- a/tests/lcitool/mappings.yml +++ b/tests/lcitool/mappings.yml @@ -59,6 +59,10 @@ mappings: CentOSStream8: OpenSUSELeap15: + python3-sqlite3: +CentOSStream8: python38 +OpenSUSELeap15: python311 + python3-tomli: # test using tomllib apk: diff --git a/tests/lcitool/projects/qemu.yml b/tests/lcitool/projects/qemu.yml index 82092c9f175..149b15de57b 100644 --- a/tests/lcitool/projects/qemu.yml +++ b/tests/lcitool/projects/qemu.yml @@ -97,6 +97,7 @@ packages: - python3-pip - python3-sphinx - python3-sphinx-rtd-theme + - python3-sqlite3 - python3-tomli - python3-venv - rpm2cpio -- 2.39.2 ___ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-le...@lists.libvirt.org
[PATCH 3/5] configure: run plugin TCG tests again
From: Paolo Bonzini Commit 39fb3cfc28b ("configure: clean up plugin option handling", 2023-10-18) dropped the CONFIG_PLUGIN line from tests/tcg/config-host.mak, due to confusion caused by the shadowing of $config_host_mak. However, TCG tests were still expecting it. Oops. Put it back, in the meanwhile the shadowing is gone so it's clear that it goes in the tests/tcg configuration. Cc: Fixes: 39fb3cfc28b ("configure: clean up plugin option handling", 2023-10-18) Signed-off-by: Paolo Bonzini Message-Id: <20240124115332.612162-1-pbonz...@redhat.com> Signed-off-by: Alex Bennée --- configure | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configure b/configure index 3d8e24ae011..ff058d6c486 100755 --- a/configure +++ b/configure @@ -1644,6 +1644,9 @@ fi mkdir -p tests/tcg echo "# Automatically generated by configure - do not modify" > tests/tcg/$config_host_mak echo "SRC_PATH=$source_path" >> tests/tcg/$config_host_mak +if test "$plugins" = "yes" ; then +echo "CONFIG_PLUGIN=y" >> tests/tcg/$config_host_mak +fi tcg_tests_targets= for target in $target_list; do -- 2.39.2 ___ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-le...@lists.libvirt.org
[PATCH 0/5] maintainer updates for 9.0 (docker, plugin tests, deprecation, elf, semihosting)
A fairly random collection of fixes in this tree. I've still got a report of openbsd rebuilding which is confusing me but I didn't want to hold up getting eyes on real fixes. The plugins register support may get added to the PR if it gets any review. The following need review: Revert "hw/elf_ops: Ignore loadable segments with zero size" docs: mark CRIS support as deprecated Alex. Alex Bennée (2): docs: mark CRIS support as deprecated Revert "hw/elf_ops: Ignore loadable segments with zero size" Fabiano Rosas (1): tests/docker: Add sqlite3 module to openSUSE Leap container Paolo Bonzini (2): configure: run plugin TCG tests again kconfig: use "select" to enable semihosting docs/about/deprecated.rst | 8 ++ configure | 3 + configs/devices/m68k-softmmu/default.mak | 2 - configs/devices/mips-softmmu/common.mak | 3 - configs/devices/nios2-softmmu/default.mak | 2 - configs/devices/riscv32-softmmu/default.mak | 2 - configs/devices/riscv64-softmmu/default.mak | 2 - configs/devices/xtensa-softmmu/default.mak| 2 - include/hw/elf_ops.h | 75 +-- target/m68k/Kconfig | 1 + target/mips/Kconfig | 1 + target/nios2/Kconfig | 1 + target/riscv/Kconfig | 2 + target/xtensa/Kconfig | 1 + tests/docker/dockerfiles/opensuse-leap.docker | 1 + tests/lcitool/mappings.yml| 4 + tests/lcitool/projects/qemu.yml | 1 + 17 files changed, 59 insertions(+), 52 deletions(-) -- 2.39.2 ___ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-le...@lists.libvirt.org
[PATCH 2/5] docs: mark CRIS support as deprecated
This might be premature but while streamling the avocado tests I realised the only tests we have are "check-tcg" ones. The aging fedora-criss-cross image works well enough for developers but can't be used in CI as we need supported build platforms to build QEMU. Does this mean the writing is on the wall for this architecture? Signed-off-by: Alex Bennée Cc: Rabin Vincent Cc: Edgar E. Iglesias Message-Id: <20230925144854.1872513-5-alex.ben...@linaro.org> --- docs/about/deprecated.rst | 8 1 file changed, 8 insertions(+) diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index d4492b94604..82922476d72 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -183,6 +183,14 @@ Nios II CPU (since 8.2) The Nios II architecture is orphan. The ``nios2`` guest CPU support is deprecated and will be removed in a future version of QEMU. +CRIS CPU architecture (since 9.0) +' + +The CRIS architecture was pulled from Linux in 4.17 and the compiler +is no longer packaged in any distro making it harder to run the +``check-tcg`` tests. Unless we can improve the testing situation there +is a chance the code will bitrot without anyone noticing. + System emulator machines -- 2.39.2 ___ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-le...@lists.libvirt.org
Re: [PATCH 04/11] nodedev: add an active config to mdev
On 1/31/24 22:30, Jonathon Jongsma wrote: On 1/19/24 10:38 AM, Boris Fiuczynski wrote: The configuration of a defined mdev can be modified after the mdev is started. The defined configuration and the active configuration can therefore run out of sync. Handle this by storing the modifiable data which is the mdev type and attributes in two separate active and defined configurations. mdevctl supports with callout scripts to do an attribute retrieval of started mdevs which is already implemented in libvirt. Signed-off-by: Boris Fiuczynski --- include/libvirt/libvirt-nodedev.h | 11 src/conf/node_device_conf.c | 53 ++-- src/conf/node_device_conf.h | 5 +- src/libvirt-nodedev.c | 2 +- src/node_device/node_device_driver.c | 61 +-- src/node_device/node_device_driver.h | 6 +- src/node_device/node_device_udev.c | 4 +- src/test/test_driver.c | 6 +- tests/nodedevmdevctltest.c | 4 +- ...v_c60cc60c_c60c_c60c_c60c_c60cc60cc60c.xml | 14 + ...d_b7f0_4fea_b468_f1da537d301b_inactive.xml | 1 + ...v_c60cc60c_c60c_c60c_c60c_c60cc60cc60c.xml | 10 +++ ...c_c60c_c60c_c60c_c60cc60cc60c_inactive.xml | 9 +++ ...9_36ea_4111_8f0a_8c9a70e21366_inactive.xml | 1 + ...9_495e_4243_ad9f_beb3f14c23d9_inactive.xml | 1 + ...4_f554_4dc1_809d_b2a01e8e48ad_inactive.xml | 8 +++ ...6_1ca8_49ac_b176_871d16c13076_inactive.xml | 1 + tests/nodedevxml2xmltest.c | 59 +++--- 18 files changed, 197 insertions(+), 59 deletions(-) create mode 100644 tests/nodedevschemadata/mdev_c60cc60c_c60c_c60c_c60c_c60cc60cc60c.xml create mode 12 tests/nodedevxml2xmlout/mdev_3627463d_b7f0_4fea_b468_f1da537d301b_inactive.xml create mode 100644 tests/nodedevxml2xmlout/mdev_c60cc60c_c60c_c60c_c60c_c60cc60cc60c.xml create mode 100644 tests/nodedevxml2xmlout/mdev_c60cc60c_c60c_c60c_c60c_c60cc60cc60c_inactive.xml create mode 12 tests/nodedevxml2xmlout/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366_inactive.xml create mode 12 tests/nodedevxml2xmlout/mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9_inactive.xml create mode 100644 tests/nodedevxml2xmlout/mdev_ee0b88c4_f554_4dc1_809d_b2a01e8e48ad_inactive.xml create mode 12 tests/nodedevxml2xmlout/mdev_fedc4916_1ca8_49ac_b176_871d16c13076_inactive.xml diff --git a/include/libvirt/libvirt-nodedev.h b/include/libvirt/libvirt-nodedev.h index 428b0d722f..d18246e2f6 100644 --- a/include/libvirt/libvirt-nodedev.h +++ b/include/libvirt/libvirt-nodedev.h @@ -117,6 +117,17 @@ int virNodeDeviceListCaps (virNodeDevicePtr dev, char **const names, int maxnames); +/** + * virNodeDeviceGetXMLDescFlags: + * + * Flags used to provide the state of the returned node device configuration. + * + * Since: 10.1.0 + */ +typedef enum { + VIR_NODE_DEVICE_GET_XML_DESC_INACTIVE = 1 << 0, /* dump inactive device configuration (Since: 10.1.0) */ +} virNodeDeviceGetXMLDescFlags; In all of the other similar cases, this type is named vir$(OBJECT)XMLFlags and the flag itself is named VIR_$(OBJECT)_XML_INACTIVE. So for consistency, I'd remove the 'get' and the 'desc' from the names. I disagree as all other methods that make use of flags base the flags names on the method name. Here are the examples: virNodeDeviceCreateXML virNodeDeviceCreateXMLFlags vir Node Device Create XML VIR_NODE_DEVICE_CREATE_XML_* virNodeDeviceDefineXML virNodeDeviceDefineXMLFlags vir Node Device Define XML VIR_NODE_DEVICE_DEFINE_XML_* virConnectListAllNodeDevices virConnectListAllNodeDeviceFlags vir Connect List Node Device [All is removed] VIR_CONNECT_LIST_NODE_DEVICES_* These are the reasons I chose for consistency: virNodeDeviceGetXMLDesc virNodeDeviceGetXMLDescFlags vir Node Device Get XML Desc VIR_NODE_DEVICE_GET_XML_DESC_INACTIVE + char * virNodeDeviceGetXMLDesc (virNodeDevicePtr dev, unsigned int flags); diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 9a0fc68e67..40e15ef4da 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -599,16 +599,22 @@ virNodeDeviceCapMdevAttrFormat(virBuffer *buf, static void virNodeDeviceCapMdevDefFormat(virBuffer *buf, - const virNodeDevCapData *data) + const virNodeDevCapData *data, + bool defined) { - virBufferEscapeString(buf, "\n", data->mdev.dev_config.type); + if (defined) + virBufferEscapeString(buf, "\n", data->mdev.defined_config.type); + else + virBufferEscapeString(buf, "\n", data->mdev.active_config.type); virBufferEscapeString(buf, "%s\n",
[PATCH 3/4] qemu: monitor: Use 'backing-mask-protocol' for blockjobs when available
Store whether qemu supports the appropriate option for block-stream and block-commit commands and always use it if available. Signed-off-by: Peter Krempa --- src/qemu/qemu_monitor.c | 1 + src/qemu/qemu_monitor_json.c | 10 ++ src/qemu/qemu_monitor_priv.h | 2 ++ 3 files changed, 13 insertions(+) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index a1773d86d4..7f3e4de329 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -624,6 +624,7 @@ qemuMonitorOpenInternal(virDomainObj *vm, if (priv) { mon->objectAddNoWrap = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_JSON); mon->queryNamedBlockNodesFlat = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_QMP_QUERY_NAMED_BLOCK_NODES_FLAT); +mon->blockjobMaskProtocol = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKJOB_BACKING_MASK_PROTOCOL); } if (virSetCloseExec(mon->fd) < 0) { diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index e114b6bfb1..7aab34c7c4 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4036,6 +4036,10 @@ qemuMonitorJSONBlockCommit(qemuMonitor *mon, g_autoptr(virJSONValue) cmd = NULL; g_autoptr(virJSONValue) reply = NULL; virTristateBool autodismiss = VIR_TRISTATE_BOOL_NO; +virTristateBool backingProtocol = VIR_TRISTATE_BOOL_ABSENT; + +if (mon->blockjobMaskProtocol) +backingProtocol = VIR_TRISTATE_BOOL_YES; cmd = qemuMonitorJSONMakeCommand("block-commit", "s:device", device, @@ -4046,6 +4050,7 @@ qemuMonitorJSONBlockCommit(qemuMonitor *mon, "S:backing-file", backingName, "T:auto-finalize", autofinalize, "T:auto-dismiss", autodismiss, + "T:backing-mask-protocol", backingProtocol, NULL); if (!cmd) return -1; @@ -4315,6 +4320,10 @@ qemuMonitorJSONBlockStream(qemuMonitor *mon, g_autoptr(virJSONValue) reply = NULL; virTristateBool autofinalize = VIR_TRISTATE_BOOL_YES; virTristateBool autodismiss = VIR_TRISTATE_BOOL_NO; +virTristateBool backingProtocol = VIR_TRISTATE_BOOL_ABSENT; + +if (mon->blockjobMaskProtocol) +backingProtocol = VIR_TRISTATE_BOOL_YES; if (!(cmd = qemuMonitorJSONMakeCommand("block-stream", "s:device", device, @@ -4324,6 +4333,7 @@ qemuMonitorJSONBlockStream(qemuMonitor *mon, "S:backing-file", backingName, "T:auto-finalize", autofinalize, "T:auto-dismiss", autodismiss, + "T:backing-mask-protocol", backingProtocol, NULL))) return -1; diff --git a/src/qemu/qemu_monitor_priv.h b/src/qemu/qemu_monitor_priv.h index 0826a1da94..0c2098c456 100644 --- a/src/qemu/qemu_monitor_priv.h +++ b/src/qemu/qemu_monitor_priv.h @@ -92,6 +92,8 @@ struct _qemuMonitor { bool objectAddNoWrap; /* query-named-block-nodes supports the 'flat' option */ bool queryNamedBlockNodesFlat; +/* use the backing-mask-protocol flag of block-commit/stream */ +bool blockjobMaskProtocol; }; -- 2.43.0 ___ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-le...@lists.libvirt.org
[PATCH 2/4] qemu: capabilities: Introduce QEMU_CAPS_BLOCKJOB_BACKING_MASK_PROTOCOL
The capability is asserted when both block-stream and block-commit QMP commands support the 'backing-mask-protocol' argument. The argument causes qemu to record 'raw' as the backing file format in case when a protocol node is used directly. This is needed to preserve compatibility of images after a block-commit or block-pull libvirt operation with older libvirt versions in case when we'll want to remove the unneded 'raw' format drivers from the block graph. Signed-off-by: Peter Krempa --- src/qemu/qemu_capabilities.c | 7 +++ src/qemu/qemu_capabilities.h | 3 +++ tests/qemucapabilitiesdata/caps_9.0.0_x86_64.xml | 1 + 3 files changed, 11 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index f4b4f05479..e383d85920 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -701,6 +701,9 @@ VIR_ENUM_IMPL(virQEMUCaps, "virtio-blk.iothread-mapping", /* QEMU_CAPS_VIRTIO_BLK_IOTHREAD_MAPPING */ "smp-clusters", /* QEMU_CAPS_SMP_CLUSTERS */ "virtio-mem-pci.dynamic-memslots", /* QEMU_CAPS_DEVICE_VIRTIO_MEM_PCI_DYNAMIC_MEMSLOTS */ + + /* 455 */ + "blockjob.backing-mask-protocol", /* QEMU_CAPS_BLOCKJOB_BACKING_MASK_PROTOCOL */ ); @@ -5425,6 +5428,10 @@ virQEMUCapsProbeQMPSchemaCapabilities(virQEMUCaps *qemuCaps, virQEMUCapsSet(qemuCaps, cmd->flag); } +if (virQEMUQAPISchemaPathExists("block-commit/arg-type/backing-mask-protocol", schema) && + virQEMUQAPISchemaPathExists("block-stream/arg-type/backing-mask-protocol", schema)) +virQEMUCapsSet(qemuCaps, QEMU_CAPS_BLOCKJOB_BACKING_MASK_PROTOCOL); + return 0; } diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 1b5130a1d3..486a4a6f63 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -681,6 +681,9 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */ QEMU_CAPS_SMP_CLUSTERS, /* -smp clusters= */ QEMU_CAPS_DEVICE_VIRTIO_MEM_PCI_DYNAMIC_MEMSLOTS, /* -device virtio-mem-pci.dynamic-memslots= */ +/* 455 */ +QEMU_CAPS_BLOCKJOB_BACKING_MASK_PROTOCOL, /* backing-mask-protocol of block-commit/block-stream */ + QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.xml b/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.xml index a1859fbf6d..7bf13da1db 100644 --- a/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.xml @@ -201,6 +201,7 @@ + 8002050 43100245 v8.2.0-952-g14639717bf -- 2.43.0 ___ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-le...@lists.libvirt.org
[PATCH 1/4] tests: qemucapabilitiesdata: Update 'caps_9.0.0_x86_64.replies'
Update to 'v8.2.0-952-g14639717bf'. Notable changes: - 'backing-mask-protocol' feature added for block-commit and block-stream - 'singlestep' mode dropped - 'cmpccxadd' cpu feature became available Signed-off-by: Peter Krempa --- For reference is the difference between the versions judged by the new scripts/qemu-replies-tool.py: $ diff -u old new | grep '^[+-]' --- old 2024-02-01 12:55:07.570896479 +0100 +++ new 2024-02-01 12:54:56.301095498 +0100 +(qmp) block-commit/arg-type/backing-mask-protocol +(qmp) block-commit/arg-type/backing-mask-protocol/!bool +(qmp) block-stream/arg-type/backing-mask-protocol +(qmp) block-stream/arg-type/backing-mask-protocol/!bool -(qmp) query-status/ret-type/singlestep -(qmp) query-status/ret-type/singlestep/$deprecated -(qmp) query-status/ret-type/singlestep/!bool The differnece in ordering of the devices and the ordering of 'start-powered-off' is properly ignored. .../domaincapsdata/qemu_9.0.0-tcg.x86_64.xml | 1 + .../caps_9.0.0_x86_64.replies | 40 ++- .../caps_9.0.0_x86_64.xml | 4 +- ...host-model-fallback-tcg.x86_64-latest.args | 2 +- ...st-model-nofallback-tcg.x86_64-latest.args | 2 +- .../cpu-host-model-tcg.x86_64-latest.args | 2 +- 6 files changed, 28 insertions(+), 23 deletions(-) diff --git a/tests/domaincapsdata/qemu_9.0.0-tcg.x86_64.xml b/tests/domaincapsdata/qemu_9.0.0-tcg.x86_64.xml index 7fcf2f8bc5..ab81e07510 100644 --- a/tests/domaincapsdata/qemu_9.0.0-tcg.x86_64.xml +++ b/tests/domaincapsdata/qemu_9.0.0-tcg.x86_64.xml @@ -52,6 +52,7 @@ + diff --git a/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.replies b/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.replies index f13457a763..2b67f89436 100644 --- a/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.replies +++ b/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.replies @@ -20,7 +20,7 @@ "minor": 2, "major": 8 }, -"package": "v8.2.0-196-g7425b6277f" +"package": "v8.2.0-952-g14639717bf" }, "id": "libvirt-2" } @@ -1775,13 +1775,6 @@ "name": "running", "type": "bool" }, -{ - "name": "singlestep", - "type": "bool", - "features": [ -"deprecated" - ] -}, { "name": "status", "type": "280" @@ -2685,6 +2678,11 @@ "default": null, "type": "str" }, +{ + "name": "backing-mask-protocol", + "default": null, + "type": "bool" +}, { "name": "speed", "default": null, @@ -3315,6 +3313,11 @@ "default": null, "type": "str" }, +{ + "name": "backing-mask-protocol", + "default": null, + "type": "bool" +}, { "name": "bottom", "default": null, @@ -6123,6 +6126,7 @@ "members": [ { "name": "uri", + "default": null, "type": "str" }, { @@ -24032,6 +24036,10 @@ "name": "KnightsMill-x86_64-cpu", "parent": "x86_64-cpu" }, +{ + "name": "chardev-udp", + "parent": "chardev" +}, { "name": "i2c-bus", "parent": "bus" @@ -24160,10 +24168,6 @@ "name": "i82557a", "parent": "pci-device" }, -{ - "name": "chardev-udp", - "parent": "chardev" -}, { "name": "pc-q35-2.8-machine", "parent": "generic-pc-machine" @@ -31052,14 +31056,14 @@ "name": "memory", "type": "link" }, -{ - "name": "start-powered-off", - "type": "bool" -}, { "name": "legacy-memory", "type": "str" }, +{ + "name": "start-powered-off", + "type": "bool" +}, { "name": "vmx-invept-single-context", "type": "bool" @@ -41772,7 +41776,7 @@ "perfctr-nb": false, "rdrand": true, "rdseed": true, -"cmpccxadd": false, +"cmpccxadd": true, "avx512-4vnniw": false, "vme": false, "vmx": false, @@ -42153,7 +42157,7 @@ "perfctr-nb": false, "rdrand": true, "rdseed": true, -"cmpccxadd": false, +"cmpccxadd": true, "avx512-4vnniw": false, "vme": false, "vmx": false, diff --git a/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.xml b/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.xml index d8e6b309e3..a1859fbf6d 100644 --- a/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.xml @@ -203,7 +203,7 @@ 8002050 43100245 - v8.2.0-196-g7425b6277f + v8.2.0-952-g14639717bf x86_64 @@ -2273,7 +2273,7 @@ - + diff --git a/tests/qemuxmlconfdata/cpu-host-model-fallback-tcg.x86_64-latest.args
[PATCH 0/4] qemu: Stop adding 'raw' -blockdev layer unless necessary
Peter Krempa (4): tests: qemucapabilitiesdata: Update 'caps_9.0.0_x86_64.replies' qemu: capabilities: Introduce QEMU_CAPS_BLOCKJOB_BACKING_MASK_PROTOCOL qemu: monitor: Use 'backing-mask-protocol' for blockjobs when available qemuBlockStorageSourceNeedsFormatLayer: Stop formatting 'raw' driver when not needed src/qemu/qemu_block.c | 28 +- src/qemu/qemu_block.h | 3 +- src/qemu/qemu_capabilities.c | 7 + src/qemu/qemu_capabilities.h | 3 + src/qemu/qemu_domain.c| 2 +- src/qemu/qemu_monitor.c | 1 + src/qemu/qemu_monitor_json.c | 10 + src/qemu/qemu_monitor_priv.h | 2 + .../domaincapsdata/qemu_9.0.0-tcg.x86_64.xml | 1 + .../caps_9.0.0_x86_64.replies | 40 +- .../caps_9.0.0_x86_64.xml | 5 +- tests/qemuhotplugtest.c | 15 - .../async-teardown.x86_64-latest.args | 5 +- .../audio-alsa-best.x86_64-latest.args| 5 +- .../audio-alsa-full.x86_64-latest.args| 5 +- .../audio-alsa-minimal.x86_64-latest.args | 5 +- .../audio-coreaudio-best.x86_64-latest.args | 5 +- .../audio-coreaudio-full.x86_64-latest.args | 5 +- ...audio-coreaudio-minimal.x86_64-latest.args | 5 +- ...udio-default-nographics.x86_64-latest.args | 5 +- .../audio-default-sdl.x86_64-latest.args | 5 +- .../audio-default-spice.x86_64-latest.args| 5 +- .../audio-default-vnc.x86_64-latest.args | 5 +- .../audio-file-best.x86_64-latest.args| 5 +- .../audio-file-full.x86_64-latest.args| 5 +- .../audio-file-minimal.x86_64-latest.args | 5 +- .../audio-jack-full.x86_64-latest.args| 5 +- .../audio-jack-minimal.x86_64-latest.args | 5 +- .../audio-many-backends.x86_64-latest.args| 5 +- .../audio-none-best.x86_64-latest.args| 5 +- .../audio-none-full.x86_64-latest.args| 5 +- .../audio-none-minimal.x86_64-latest.args | 5 +- .../audio-oss-best.x86_64-latest.args | 5 +- .../audio-oss-full.x86_64-latest.args | 5 +- .../audio-oss-minimal.x86_64-latest.args | 5 +- .../audio-pipewire-best.x86_64-latest.args| 5 +- .../audio-pipewire-full.x86_64-latest.args| 5 +- .../audio-pipewire-minimal.x86_64-latest.args | 5 +- .../audio-pulseaudio-best.x86_64-latest.args | 5 +- .../audio-pulseaudio-full.x86_64-latest.args | 5 +- ...udio-pulseaudio-minimal.x86_64-latest.args | 5 +- .../audio-sdl-best.x86_64-latest.args | 5 +- .../audio-sdl-full.x86_64-latest.args | 5 +- .../audio-sdl-minimal.x86_64-latest.args | 5 +- .../audio-spice-best.x86_64-latest.args | 5 +- .../audio-spice-full.x86_64-latest.args | 5 +- .../audio-spice-minimal.x86_64-latest.args| 5 +- .../autoindex.x86_64-latest.args | 5 +- .../balloon-device-auto.x86_64-latest.args| 5 +- ...loon-device-deflate-off.x86_64-latest.args | 5 +- .../balloon-device-deflate.x86_64-latest.args | 5 +- .../balloon-device-period.x86_64-latest.args | 5 +- .../balloon-device.x86_64-latest.args | 5 +- .../blkiotune-device.x86_64-latest.args | 5 +- .../blkiotune.x86_64-latest.args | 5 +- .../boot-cdrom.x86_64-latest.args | 5 +- .../boot-complex.x86_64-latest.args | 35 +- .../boot-floppy-q35.x86_64-latest.args| 5 +- .../boot-floppy.x86_64-latest.args| 10 +- ...boot-menu-disable-drive.x86_64-latest.args | 5 +- ...nu-disable-with-timeout.x86_64-latest.args | 5 +- .../boot-menu-disable.x86_64-latest.args | 5 +- ...enu-enable-with-timeout.x86_64-latest.args | 5 +- .../boot-menu-enable.x86_64-latest.args | 5 +- .../boot-multi.x86_64-latest.args | 5 +- .../boot-network.x86_64-latest.args | 5 +- .../boot-order.x86_64-latest.args | 20 +- .../channel-guestfwd.x86_64-latest.args | 5 +- ...l-qemu-vdagent-features.x86_64-latest.args | 5 +- .../channel-qemu-vdagent.x86_64-latest.args | 5 +- .../channel-spicevmc.x86_64-latest.args | 5 +- .../channel-virtio-auto.x86_64-latest.args| 5 +- .../channel-virtio-autoadd.x86_64-latest.args | 5 +- ...annel-virtio-autoassign.x86_64-latest.args | 5 +- .../channel-virtio-default.x86_64-latest.args | 5 +- .../channel-virtio-state.x86_64-latest.args | 5 +- .../channel-virtio-unix.x86_64-latest.args| 5 +- .../channel-virtio.x86_64-latest.args | 5 +- .../clock-absolute.x86_64-latest.args | 5 +- .../clock-catchup.x86_64-latest.args | 5 +- .../clock-france.x86_64-latest.args | 5 +- .../clock-hpet-off.x86_64-latest.args | 5 +- ...caltime-basis-localtime.x86_64-latest.args | 5 +-
Re: [PATCH 02/11] node_device: refactor mdev attributes handling
On 1/31/24 22:03, Jonathon Jongsma wrote: On 1/19/24 10:38 AM, Boris Fiuczynski wrote: Refactor attribute handling code into methods for easier reuse. Signed-off-by: Boris Fiuczynski --- src/conf/node_device_conf.c | 27 --- src/node_device/node_device_driver.c | 108 --- 2 files changed, 83 insertions(+), 52 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 4e1bde503f..68924b3027 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -585,11 +585,22 @@ virNodeDeviceCapStorageDefFormat(virBuffer *buf, } static void -virNodeDeviceCapMdevDefFormat(virBuffer *buf, - const virNodeDevCapData *data) +virNodeDeviceCapMdevAttrFormat(virBuffer *buf, + const virMediatedDeviceConfig *config) { size_t i; + for (i = 0; i < config->nattributes; i++) { + virMediatedDeviceAttr *attr = config->attributes[i]; + virBufferAsprintf(buf, "\n", + attr->name, attr->value); + } +} + +static void +virNodeDeviceCapMdevDefFormat(virBuffer *buf, + const virNodeDevCapData *data) +{ virBufferEscapeString(buf, "\n", data->mdev.dev_config.type); virBufferEscapeString(buf, "%s\n", data->mdev.uuid); virBufferEscapeString(buf, "%s\n", @@ -597,11 +608,7 @@ virNodeDeviceCapMdevDefFormat(virBuffer *buf, virBufferAsprintf(buf, "\n", data->mdev.iommuGroupNumber); - for (i = 0; i < data->mdev.dev_config.nattributes; i++) { - virMediatedDeviceAttr *attr = data->mdev.dev_config.attributes[i]; - virBufferAsprintf(buf, "\n", - attr->name, attr->value); - } + virNodeDeviceCapMdevAttrFormat(buf, >mdev.dev_config); } static void @@ -2188,7 +2195,7 @@ virNodeDevCapSystemParseXML(xmlXPathContextPtr ctxt, static int virNodeDevCapMdevAttributeParseXML(xmlXPathContextPtr ctxt, xmlNodePtr node, - virNodeDevCapMdev *mdev) + virMediatedDeviceConfig *config) { VIR_XPATH_NODE_AUTORESTORE(ctxt) g_autoptr(virMediatedDeviceAttr) attr = virMediatedDeviceAttrNew(); @@ -2202,7 +2209,7 @@ virNodeDevCapMdevAttributeParseXML(xmlXPathContextPtr ctxt, return -1; } - VIR_APPEND_ELEMENT(mdev->dev_config.attributes, mdev->dev_config.nattributes, attr); + VIR_APPEND_ELEMENT(config->attributes, config->nattributes, attr); return 0; } @@ -2253,7 +2260,7 @@ virNodeDevCapMdevParseXML(xmlXPathContextPtr ctxt, return -1; for (i = 0; i < nattrs; i++) - virNodeDevCapMdevAttributeParseXML(ctxt, attrs[i], mdev); + virNodeDevCapMdevAttributeParseXML(ctxt, attrs[i], >dev_config); return 0; } diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c index 1ee59d710b..0c8612eb71 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -599,27 +599,16 @@ nodeDeviceHasCapability(virNodeDeviceDef *def, virNodeDevCapType type) } -/* format a json string that provides configuration information about this mdev - * to the mdevctl utility */ static int -nodeDeviceDefToMdevctlConfig(virNodeDeviceDef *def, char **buf) +nodeDeviceAttributesToJSON(virJSONValue *json, + const virMediatedDeviceConfig config) I don't see any compelling reason to pass this config struct by value. Just pass a pointer. Changed. { size_t i; - virNodeDevCapMdev *mdev = >caps->data.mdev; - g_autoptr(virJSONValue) json = virJSONValueNewObject(); - const char *startval = mdev->autostart ? "auto" : "manual"; - - if (virJSONValueObjectAppendString(json, "mdev_type", mdev->dev_config.type) < 0) - return -1; - - if (virJSONValueObjectAppendString(json, "start", startval) < 0) - return -1; - - if (mdev->dev_config.attributes) { + if (config.attributes) { g_autoptr(virJSONValue) attributes = virJSONValueNewArray(); - for (i = 0; i < mdev->dev_config.nattributes; i++) { - virMediatedDeviceAttr *attr = mdev->dev_config.attributes[i]; + for (i = 0; i < config.nattributes; i++) { + virMediatedDeviceAttr *attr = config.attributes[i]; g_autoptr(virJSONValue) jsonattr = virJSONValueNewObject(); if (virJSONValueObjectAppendString(jsonattr, attr->name, attr->value) < 0) @@ -633,6 +622,28 @@ nodeDeviceDefToMdevctlConfig(virNodeDeviceDef *def, char **buf) return -1; } + return 0; +} + + +/* format a json string that provides configuration information about this mdev + * to the mdevctl utility */ +static int +nodeDeviceDefToMdevctlConfig(virNodeDeviceDef *def, char **buf) +{ + virNodeDevCapMdev *mdev = >caps->data.mdev; +
Re: [libvirt PATCH] conf: Fix error message in virNetworkForwardDefParseXML
On Thu, Feb 01, 2024 at 12:16:37 +0100, Jiri Denemark wrote: > Signed-off-by: Jiri Denemark > --- > src/conf/network_conf.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c > index a2220c05a6..ef3415cd89 100644 > --- a/src/conf/network_conf.c > +++ b/src/conf/network_conf.c > @@ -1362,8 +1362,9 @@ virNetworkForwardDefParseXML(const char *networkName, > > forwardDev = virXPathString("string(./@dev)", ctxt); > if (forwardDev && (nForwardAddrs > 0 || nForwardPfs > 0)) { > -virReportError(VIR_ERR_XML_ERROR, "%s", > - _("the 'dev' attribute cannot be used when > or sub-elements are present in network %1$s")); > +virReportError(VIR_ERR_XML_ERROR, > + _("the 'dev' attribute cannot be used when > or sub-elements are present in network %1$s"), > + networkName); > return -1; > } Reviewed-by: Peter Krempa ___ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-le...@lists.libvirt.org
[libvirt PATCH] conf: Fix error message in virNetworkForwardDefParseXML
Signed-off-by: Jiri Denemark --- src/conf/network_conf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index a2220c05a6..ef3415cd89 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -1362,8 +1362,9 @@ virNetworkForwardDefParseXML(const char *networkName, forwardDev = virXPathString("string(./@dev)", ctxt); if (forwardDev && (nForwardAddrs > 0 || nForwardPfs > 0)) { -virReportError(VIR_ERR_XML_ERROR, "%s", - _("the 'dev' attribute cannot be used when or sub-elements are present in network %1$s")); +virReportError(VIR_ERR_XML_ERROR, + _("the 'dev' attribute cannot be used when or sub-elements are present in network %1$s"), + networkName); return -1; } -- 2.43.0 ___ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-le...@lists.libvirt.org