[PATCH 0/2] virnetdevopenvswitch: Get names for dpdkvhostuserclient too

The first patch fixes the actual problem, the second is just a cleanup I've came up with whilst looking at the code. Michal Prívozník (2): virnetdevopenvswitch: Get names for dpdkvhostuserclient too virnetdevopenvswitch: Simplify OVS_VSCTL cmd creation src/qemu/qemu_command.c | 1 + src/qemu/qemu_hotplug.c | 1 + src/util/virnetdevopenvswitch.c | 92 +++++++++++++++++++-------------- src/util/virnetdevopenvswitch.h | 1 + tests/qemuxml2argvmock.c | 1 + 5 files changed, 56 insertions(+), 40 deletions(-) -- 2.26.2

There are two type of vhostuser ports: dpdkvhostuser - OVS creates the socket and QEMU connects to it dpdkvhostuserclient - QEMU creates the socket and OVS connects to it But of course ovs-vsctl syntax for fetching ifname is different. So far, we've implemented the former. The lack of implementation for the latter means that we are not detecting the interface name and thus not reporting it in domain XML, or failing to get interface statistics. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1767013 Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_command.c | 1 + src/qemu/qemu_hotplug.c | 1 + src/util/virnetdevopenvswitch.c | 60 +++++++++++++++++++++++---------- src/util/virnetdevopenvswitch.h | 1 + tests/qemuxml2argvmock.c | 1 + 5 files changed, 46 insertions(+), 18 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index b0c2a5efb5..0e803145d1 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8004,6 +8004,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver, goto cleanup; if (virNetDevOpenvswitchGetVhostuserIfname(net->data.vhostuser->data.nix.path, + net->data.vhostuser->data.nix.listen, &net->ifname) < 0) goto cleanup; diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 81bbe178a9..8c22075be1 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1305,6 +1305,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, goto cleanup; if (virNetDevOpenvswitchGetVhostuserIfname(net->data.vhostuser->data.nix.path, + net->data.vhostuser->data.nix.listen, &net->ifname) < 0) goto cleanup; diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c index a7b6af594d..d809152f33 100644 --- a/src/util/virnetdevopenvswitch.c +++ b/src/util/virnetdevopenvswitch.c @@ -471,9 +471,20 @@ virNetDevOpenvswitchInterfaceGetMaster(const char *ifname, char **master) /** * virNetDevOpenvswitchVhostuserGetIfname: * @path: the path of the unix socket + * @server: true if OVS creates the @path * @ifname: the retrieved name of the interface * - * Retrieves the ovs ifname from vhostuser unix socket path. + * Retrieves the OVS ifname from vhostuser UNIX socket path. + * There are two types of vhostuser ports which differ in client/server + * role: + * + * dpdkvhostuser - OVS creates the socket and QEMU connects to it + * (@server = true) + * dpdkvhostuserclient - QEMU creates the socket and OVS connects to it + * (@server = false) + * + * Since the way of retrieving ifname is different in these two cases, + * caller must set @server according to the interface definition. * * Returns: 1 if interface is an openvswitch interface, * 0 if it is not, but no other error occurred, @@ -481,33 +492,46 @@ virNetDevOpenvswitchInterfaceGetMaster(const char *ifname, char **master) */ int virNetDevOpenvswitchGetVhostuserIfname(const char *path, + bool server, char **ifname) { - const char *tmpIfname = NULL; + g_autoptr(virCommand) cmd = NULL; int status; - g_autoptr(virCommand) cmd = NULL; - /* Openvswitch vhostuser path are hardcoded to - * /<runstatedir>/openvswitch/<ifname> - * for example: /var/run/openvswitch/dpdkvhostuser0 - * - * so we pick the filename and check it's a openvswitch interface - */ - if (!path || - !(tmpIfname = strrchr(path, '/'))) - return 0; - - tmpIfname++; cmd = virCommandNew(OVS_VSCTL); virNetDevOpenvswitchAddTimeout(cmd); - virCommandAddArgList(cmd, "get", "Interface", tmpIfname, "name", NULL); - if (virCommandRun(cmd, &status) < 0 || - status) { + + if (server) { + virCommandAddArgList(cmd, "--no-headings", "--columns=name", "find", + "Interface", NULL); + virCommandAddArgPair(cmd, "options:vhost-server-path", "path"); + } else { + const char *tmpIfname = NULL; + + /* Openvswitch vhostuser path are hardcoded to + * /<runstatedir>/openvswitch/<ifname> + * for example: /var/run/openvswitch/dpdkvhostuser0 + * + * so we pick the filename and check it's a openvswitch interface + */ + if (!path || + !(tmpIfname = strrchr(path, '/'))) { + return 0; + } + + tmpIfname++; + virCommandAddArgList(cmd, "get", "Interface", tmpIfname, "name", NULL); + } + + virCommandSetOutputBuffer(cmd, ifname); + if (virCommandRun(cmd, &status) < 0) + return -1; + + if (status != 0) { /* it's not a openvswitch vhostuser interface. */ return 0; } - *ifname = g_strdup(tmpIfname); return 1; } diff --git a/src/util/virnetdevopenvswitch.h b/src/util/virnetdevopenvswitch.h index c9ea592058..5cd1d22ae3 100644 --- a/src/util/virnetdevopenvswitch.h +++ b/src/util/virnetdevopenvswitch.h @@ -61,6 +61,7 @@ int virNetDevOpenvswitchInterfaceGetMaster(const char *ifname, char **master) ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT; int virNetDevOpenvswitchGetVhostuserIfname(const char *path, + bool server, char **ifname) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT G_GNUC_NO_INLINE; diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c index 2cdbe7e356..6900232b33 100644 --- a/tests/qemuxml2argvmock.c +++ b/tests/qemuxml2argvmock.c @@ -217,6 +217,7 @@ virCommandPassFD(virCommandPtr cmd, int virNetDevOpenvswitchGetVhostuserIfname(const char *path G_GNUC_UNUSED, + bool server G_GNUC_UNUSED, char **ifname) { *ifname = g_strdup("vhost-user0"); -- 2.26.2

On 11/11/20 5:38 AM, Michal Privoznik wrote:
There are two type of vhostuser ports:
s/type/types
dpdkvhostuser - OVS creates the socket and QEMU connects to it dpdkvhostuserclient - QEMU creates the socket and OVS connects to it
But of course ovs-vsctl syntax for fetching ifname is different. So far, we've implemented the former. The lack of implementation for the latter means that we are not detecting the interface name and thus not reporting it in domain XML, or failing to get interface statistics.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1767013
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_command.c | 1 + src/qemu/qemu_hotplug.c | 1 + src/util/virnetdevopenvswitch.c | 60 +++++++++++++++++++++++---------- src/util/virnetdevopenvswitch.h | 1 + tests/qemuxml2argvmock.c | 1 + 5 files changed, 46 insertions(+), 18 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index b0c2a5efb5..0e803145d1 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8004,6 +8004,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver, goto cleanup;
if (virNetDevOpenvswitchGetVhostuserIfname(net->data.vhostuser->data.nix.path, + net->data.vhostuser->data.nix.listen, &net->ifname) < 0) goto cleanup;
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 81bbe178a9..8c22075be1 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1305,6 +1305,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, goto cleanup;
if (virNetDevOpenvswitchGetVhostuserIfname(net->data.vhostuser->data.nix.path, + net->data.vhostuser->data.nix.listen, &net->ifname) < 0) goto cleanup;
diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c index a7b6af594d..d809152f33 100644 --- a/src/util/virnetdevopenvswitch.c +++ b/src/util/virnetdevopenvswitch.c @@ -471,9 +471,20 @@ virNetDevOpenvswitchInterfaceGetMaster(const char *ifname, char **master) /** * virNetDevOpenvswitchVhostuserGetIfname: * @path: the path of the unix socket + * @server: true if OVS creates the @path * @ifname: the retrieved name of the interface * - * Retrieves the ovs ifname from vhostuser unix socket path. + * Retrieves the OVS ifname from vhostuser UNIX socket path. + * There are two types of vhostuser ports which differ in client/server + * role: + * + * dpdkvhostuser - OVS creates the socket and QEMU connects to it + * (@server = true) + * dpdkvhostuserclient - QEMU creates the socket and OVS connects to it + * (@server = false) + * + * Since the way of retrieving ifname is different in these two cases, + * caller must set @server according to the interface definition. * * Returns: 1 if interface is an openvswitch interface, * 0 if it is not, but no other error occurred, @@ -481,33 +492,46 @@ virNetDevOpenvswitchInterfaceGetMaster(const char *ifname, char **master) */ int virNetDevOpenvswitchGetVhostuserIfname(const char *path, + bool server, char **ifname) { - const char *tmpIfname = NULL; + g_autoptr(virCommand) cmd = NULL; int status; - g_autoptr(virCommand) cmd = NULL;
- /* Openvswitch vhostuser path are hardcoded to - * /<runstatedir>/openvswitch/<ifname> - * for example: /var/run/openvswitch/dpdkvhostuser0 - * - * so we pick the filename and check it's a openvswitch interface - */ - if (!path || - !(tmpIfname = strrchr(path, '/'))) - return 0; - - tmpIfname++; cmd = virCommandNew(OVS_VSCTL); virNetDevOpenvswitchAddTimeout(cmd); - virCommandAddArgList(cmd, "get", "Interface", tmpIfname, "name", NULL); - if (virCommandRun(cmd, &status) < 0 || - status) { + + if (server) { + virCommandAddArgList(cmd, "--no-headings", "--columns=name", "find", + "Interface", NULL); + virCommandAddArgPair(cmd, "options:vhost-server-path", "path"); + } else { + const char *tmpIfname = NULL; + + /* Openvswitch vhostuser path are hardcoded to
Either 'path is hardcoded to' or 'paths are hardcoded to'.
+ * /<runstatedir>/openvswitch/<ifname> + * for example: /var/run/openvswitch/dpdkvhostuser0 + * + * so we pick the filename and check it's a openvswitch interface
s/a openvswitch/an openvswitch ps: I am aware that those were existing typos and you just moved them, but might as well fix it while you're at it :) Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
+ */ + if (!path || + !(tmpIfname = strrchr(path, '/'))) { + return 0; + } + + tmpIfname++; + virCommandAddArgList(cmd, "get", "Interface", tmpIfname, "name", NULL); + } + + virCommandSetOutputBuffer(cmd, ifname); + if (virCommandRun(cmd, &status) < 0) + return -1; + + if (status != 0) { /* it's not a openvswitch vhostuser interface. */ return 0; }
- *ifname = g_strdup(tmpIfname); return 1; }
diff --git a/src/util/virnetdevopenvswitch.h b/src/util/virnetdevopenvswitch.h index c9ea592058..5cd1d22ae3 100644 --- a/src/util/virnetdevopenvswitch.h +++ b/src/util/virnetdevopenvswitch.h @@ -61,6 +61,7 @@ int virNetDevOpenvswitchInterfaceGetMaster(const char *ifname, char **master) ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT;
int virNetDevOpenvswitchGetVhostuserIfname(const char *path, + bool server, char **ifname) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT G_GNUC_NO_INLINE;
diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c index 2cdbe7e356..6900232b33 100644 --- a/tests/qemuxml2argvmock.c +++ b/tests/qemuxml2argvmock.c @@ -217,6 +217,7 @@ virCommandPassFD(virCommandPtr cmd,
int virNetDevOpenvswitchGetVhostuserIfname(const char *path G_GNUC_UNUSED, + bool server G_GNUC_UNUSED, char **ifname) { *ifname = g_strdup("vhost-user0");

On 11/11/20 3:38 AM, Michal Privoznik wrote:
There are two type of vhostuser ports:
dpdkvhostuser - OVS creates the socket and QEMU connects to it dpdkvhostuserclient - QEMU creates the socket and OVS connects to it
But of course ovs-vsctl syntax for fetching ifname is different. So far, we've implemented the former. The lack of implementation for the latter means that we are not detecting the interface name and thus not reporting it in domain XML, or failing to get interface statistics.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1767013
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_command.c | 1 + src/qemu/qemu_hotplug.c | 1 + src/util/virnetdevopenvswitch.c | 60 +++++++++++++++++++++++---------- src/util/virnetdevopenvswitch.h | 1 + tests/qemuxml2argvmock.c | 1 + 5 files changed, 46 insertions(+), 18 deletions(-)
[...]
diff --git a/src/util/virnetdevopenvswitch.h b/src/util/virnetdevopenvswitch.h index c9ea592058..5cd1d22ae3 100644 --- a/src/util/virnetdevopenvswitch.h +++ b/src/util/virnetdevopenvswitch.h @@ -61,6 +61,7 @@ int virNetDevOpenvswitchInterfaceGetMaster(const char *ifname, char **master) ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT;
int virNetDevOpenvswitchGetVhostuserIfname(const char *path, + bool server, char **ifname) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT G_GNUC_NO_INLINE;
^^ A coverity build breaker... s/(2)/(3) will resolve. John

Every time we create new virCommand of OVS_VSCTL it must be followed by virNetDevOpenvswitchAddTimeout() call which adds the --timeout=X argument to freshly created cmd. Instead of having this as two separate function calls it can be just one. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/util/virnetdevopenvswitch.c | 36 +++++++++++---------------------- 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c index d809152f33..45554012ea 100644 --- a/src/util/virnetdevopenvswitch.c +++ b/src/util/virnetdevopenvswitch.c @@ -51,10 +51,12 @@ virNetDevOpenvswitchSetTimeout(unsigned int timeout) virNetDevOpenvswitchTimeout = timeout; } -static void -virNetDevOpenvswitchAddTimeout(virCommandPtr cmd) +static virCommandPtr +virNetDevOpenvswitchCreateCmd(void) { + virCommandPtr cmd = virCommandNew(OVS_VSCTL); virCommandAddArgFormat(cmd, "--timeout=%u", virNetDevOpenvswitchTimeout); + return cmd; } /** @@ -151,8 +153,7 @@ int virNetDevOpenvswitchAddPort(const char *brname, const char *ifname, ovsport->profileID); } - cmd = virCommandNew(OVS_VSCTL); - virNetDevOpenvswitchAddTimeout(cmd); + cmd = virNetDevOpenvswitchCreateCmd(); virCommandAddArgList(cmd, "--", "--if-exists", "del-port", ifname, "--", "add-port", brname, ifname, NULL); @@ -197,10 +198,8 @@ int virNetDevOpenvswitchAddPort(const char *brname, const char *ifname, */ int virNetDevOpenvswitchRemovePort(const char *brname G_GNUC_UNUSED, const char *ifname) { - g_autoptr(virCommand) cmd = NULL; + g_autoptr(virCommand) cmd = virNetDevOpenvswitchCreateCmd(); - cmd = virCommandNew(OVS_VSCTL); - virNetDevOpenvswitchAddTimeout(cmd); virCommandAddArgList(cmd, "--", "--if-exists", "del-port", ifname, NULL); if (virCommandRun(cmd, NULL) < 0) { @@ -224,10 +223,8 @@ int virNetDevOpenvswitchRemovePort(const char *brname G_GNUC_UNUSED, const char int virNetDevOpenvswitchGetMigrateData(char **migrate, const char *ifname) { size_t len; - g_autoptr(virCommand) cmd = NULL; + g_autoptr(virCommand) cmd = virNetDevOpenvswitchCreateCmd(); - cmd = virCommandNew(OVS_VSCTL); - virNetDevOpenvswitchAddTimeout(cmd); virCommandAddArgList(cmd, "--if-exists", "get", "Interface", ifname, "external_ids:PortData", NULL); @@ -267,8 +264,7 @@ int virNetDevOpenvswitchSetMigrateData(char *migrate, const char *ifname) return 0; } - cmd = virCommandNew(OVS_VSCTL); - virNetDevOpenvswitchAddTimeout(cmd); + cmd = virNetDevOpenvswitchCreateCmd(); virCommandAddArgList(cmd, "set", "Interface", ifname, NULL); virCommandAddArgFormat(cmd, "external_ids:PortData=%s", migrate); @@ -370,11 +366,9 @@ int virNetDevOpenvswitchInterfaceStats(const char *ifname, virDomainInterfaceStatsPtr stats) { - g_autoptr(virCommand) cmd = NULL; + g_autoptr(virCommand) cmd = virNetDevOpenvswitchCreateCmd(); g_autofree char *output = NULL; - cmd = virCommandNew(OVS_VSCTL); - virNetDevOpenvswitchAddTimeout(cmd); virCommandAddArgList(cmd, "--if-exists", "--format=list", "--data=json", "--no-headings", "--columns=statistics", "list", "Interface", ifname, NULL); @@ -434,13 +428,11 @@ virNetDevOpenvswitchInterfaceStats(const char *ifname, int virNetDevOpenvswitchInterfaceGetMaster(const char *ifname, char **master) { - virCommandPtr cmd = NULL; + virCommandPtr cmd = virNetDevOpenvswitchCreateCmd(); int exitstatus; *master = NULL; - cmd = virCommandNew(OVS_VSCTL); - virNetDevOpenvswitchAddTimeout(cmd); virCommandAddArgList(cmd, "iface-to-br", ifname, NULL); virCommandSetOutputBuffer(cmd, master); @@ -495,11 +487,9 @@ virNetDevOpenvswitchGetVhostuserIfname(const char *path, bool server, char **ifname) { - g_autoptr(virCommand) cmd = NULL; + g_autoptr(virCommand) cmd = virNetDevOpenvswitchCreateCmd(); int status; - cmd = virCommandNew(OVS_VSCTL); - virNetDevOpenvswitchAddTimeout(cmd); if (server) { virCommandAddArgList(cmd, "--no-headings", "--columns=name", "find", @@ -547,10 +537,8 @@ virNetDevOpenvswitchGetVhostuserIfname(const char *path, int virNetDevOpenvswitchUpdateVlan(const char *ifname, const virNetDevVlan *virtVlan) { - g_autoptr(virCommand) cmd = NULL; + g_autoptr(virCommand) cmd = virNetDevOpenvswitchCreateCmd(); - cmd = virCommandNew(OVS_VSCTL); - virNetDevOpenvswitchAddTimeout(cmd); virCommandAddArgList(cmd, "--", "--if-exists", "clear", "Port", ifname, "tag", "--", "--if-exists", "clear", "Port", ifname, "trunk", -- 2.26.2

On 11/11/20 5:38 AM, Michal Privoznik wrote:
Every time we create new virCommand of OVS_VSCTL it must be followed by virNetDevOpenvswitchAddTimeout() call which adds the --timeout=X argument to freshly created cmd. Instead of having this as two separate function calls it can be just one.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> ---
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
src/util/virnetdevopenvswitch.c | 36 +++++++++++---------------------- 1 file changed, 12 insertions(+), 24 deletions(-)
diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c index d809152f33..45554012ea 100644 --- a/src/util/virnetdevopenvswitch.c +++ b/src/util/virnetdevopenvswitch.c @@ -51,10 +51,12 @@ virNetDevOpenvswitchSetTimeout(unsigned int timeout) virNetDevOpenvswitchTimeout = timeout; }
-static void -virNetDevOpenvswitchAddTimeout(virCommandPtr cmd) +static virCommandPtr +virNetDevOpenvswitchCreateCmd(void) { + virCommandPtr cmd = virCommandNew(OVS_VSCTL); virCommandAddArgFormat(cmd, "--timeout=%u", virNetDevOpenvswitchTimeout); + return cmd; }
/** @@ -151,8 +153,7 @@ int virNetDevOpenvswitchAddPort(const char *brname, const char *ifname, ovsport->profileID); }
- cmd = virCommandNew(OVS_VSCTL); - virNetDevOpenvswitchAddTimeout(cmd); + cmd = virNetDevOpenvswitchCreateCmd(); virCommandAddArgList(cmd, "--", "--if-exists", "del-port", ifname, "--", "add-port", brname, ifname, NULL);
@@ -197,10 +198,8 @@ int virNetDevOpenvswitchAddPort(const char *brname, const char *ifname, */ int virNetDevOpenvswitchRemovePort(const char *brname G_GNUC_UNUSED, const char *ifname) { - g_autoptr(virCommand) cmd = NULL; + g_autoptr(virCommand) cmd = virNetDevOpenvswitchCreateCmd();
- cmd = virCommandNew(OVS_VSCTL); - virNetDevOpenvswitchAddTimeout(cmd); virCommandAddArgList(cmd, "--", "--if-exists", "del-port", ifname, NULL);
if (virCommandRun(cmd, NULL) < 0) { @@ -224,10 +223,8 @@ int virNetDevOpenvswitchRemovePort(const char *brname G_GNUC_UNUSED, const char int virNetDevOpenvswitchGetMigrateData(char **migrate, const char *ifname) { size_t len; - g_autoptr(virCommand) cmd = NULL; + g_autoptr(virCommand) cmd = virNetDevOpenvswitchCreateCmd();
- cmd = virCommandNew(OVS_VSCTL); - virNetDevOpenvswitchAddTimeout(cmd); virCommandAddArgList(cmd, "--if-exists", "get", "Interface", ifname, "external_ids:PortData", NULL);
@@ -267,8 +264,7 @@ int virNetDevOpenvswitchSetMigrateData(char *migrate, const char *ifname) return 0; }
- cmd = virCommandNew(OVS_VSCTL); - virNetDevOpenvswitchAddTimeout(cmd); + cmd = virNetDevOpenvswitchCreateCmd(); virCommandAddArgList(cmd, "set", "Interface", ifname, NULL); virCommandAddArgFormat(cmd, "external_ids:PortData=%s", migrate);
@@ -370,11 +366,9 @@ int virNetDevOpenvswitchInterfaceStats(const char *ifname, virDomainInterfaceStatsPtr stats) { - g_autoptr(virCommand) cmd = NULL; + g_autoptr(virCommand) cmd = virNetDevOpenvswitchCreateCmd(); g_autofree char *output = NULL;
- cmd = virCommandNew(OVS_VSCTL); - virNetDevOpenvswitchAddTimeout(cmd); virCommandAddArgList(cmd, "--if-exists", "--format=list", "--data=json", "--no-headings", "--columns=statistics", "list", "Interface", ifname, NULL); @@ -434,13 +428,11 @@ virNetDevOpenvswitchInterfaceStats(const char *ifname, int virNetDevOpenvswitchInterfaceGetMaster(const char *ifname, char **master) { - virCommandPtr cmd = NULL; + virCommandPtr cmd = virNetDevOpenvswitchCreateCmd(); int exitstatus;
*master = NULL;
- cmd = virCommandNew(OVS_VSCTL); - virNetDevOpenvswitchAddTimeout(cmd); virCommandAddArgList(cmd, "iface-to-br", ifname, NULL); virCommandSetOutputBuffer(cmd, master);
@@ -495,11 +487,9 @@ virNetDevOpenvswitchGetVhostuserIfname(const char *path, bool server, char **ifname) { - g_autoptr(virCommand) cmd = NULL; + g_autoptr(virCommand) cmd = virNetDevOpenvswitchCreateCmd(); int status;
- cmd = virCommandNew(OVS_VSCTL); - virNetDevOpenvswitchAddTimeout(cmd);
if (server) { virCommandAddArgList(cmd, "--no-headings", "--columns=name", "find", @@ -547,10 +537,8 @@ virNetDevOpenvswitchGetVhostuserIfname(const char *path, int virNetDevOpenvswitchUpdateVlan(const char *ifname, const virNetDevVlan *virtVlan) { - g_autoptr(virCommand) cmd = NULL; + g_autoptr(virCommand) cmd = virNetDevOpenvswitchCreateCmd();
- cmd = virCommandNew(OVS_VSCTL); - virNetDevOpenvswitchAddTimeout(cmd); virCommandAddArgList(cmd, "--", "--if-exists", "clear", "Port", ifname, "tag", "--", "--if-exists", "clear", "Port", ifname, "trunk",
participants (3)
-
Daniel Henrique Barboza
-
John Ferlan
-
Michal Privoznik