}
static virCommand *
-virNetDevOpenvswitchCreateCmd(void)
+virNetDevOpenvswitchCreateCmd(char **errbuf)
{
virCommand *cmd = virCommandNew(OVS_VSCTL);
+
virCommandAddArgFormat(cmd, "--timeout=%u", virNetDevOpenvswitchTimeout);
+ if (errbuf)
+ virCommandSetErrorBuffer(cmd, errbuf);
+
return cmd;
}
char ifuuidstr[VIR_UUID_STRING_BUFLEN];
char vmuuidstr[VIR_UUID_STRING_BUFLEN];
g_autoptr(virCommand) cmd = NULL;
+ g_autofree char *errbuf = NULL;
g_autofree char *attachedmac_ex_id = NULL;
g_autofree char *ifaceid_ex_id = NULL;
g_autofree char *profile_ex_id = NULL;
ovsport->profileID);
}
- cmd = virNetDevOpenvswitchCreateCmd();
+ cmd = virNetDevOpenvswitchCreateCmd(&errbuf);
virCommandAddArgList(cmd, "--", "--may-exist",
"add-port", brname, ifname, NULL);
if (virCommandRun(cmd, NULL) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Unable to add port %1$s to OVS bridge %2$s"),
- ifname, brname);
+ _("Unable to add port %1$s to OVS bridge %2$s: %3$s"),
+ ifname, brname, NULLSTR(errbuf));
return -1;
}
*/
int virNetDevOpenvswitchRemovePort(const char *brname G_GNUC_UNUSED, const char *ifname)
{
- g_autoptr(virCommand) cmd = virNetDevOpenvswitchCreateCmd();
+ g_autofree char *errbuf = NULL;
+ g_autoptr(virCommand) cmd = virNetDevOpenvswitchCreateCmd(&errbuf);
virCommandAddArgList(cmd, "--", "--if-exists", "del-port", ifname, NULL);
if (virCommandRun(cmd, NULL) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Unable to delete port %1$s from OVS"), ifname);
+ _("Unable to delete port %1$s from OVS: %2$s"),
+ ifname, NULLSTR(errbuf));
return -1;
}
int virNetDevOpenvswitchGetMigrateData(char **migrate, const char *ifname)
{
size_t len;
- g_autoptr(virCommand) cmd = virNetDevOpenvswitchCreateCmd();
+ g_autofree char *errbuf = NULL;
+ g_autoptr(virCommand) cmd = virNetDevOpenvswitchCreateCmd(&errbuf);
virCommandAddArgList(cmd, "--if-exists", "get", "Interface",
ifname, "external_ids:PortData", NULL);
/* Run the command */
if (virCommandRun(cmd, NULL) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Unable to run command to get OVS port data for interface %1$s"),
- ifname);
+ _("Unable to run command to get OVS port data for interface %1$s: %2$s"),
+ ifname, NULLSTR(errbuf));
return -1;
}
int virNetDevOpenvswitchSetMigrateData(char *migrate, const char *ifname)
{
g_autoptr(virCommand) cmd = NULL;
+ g_autofree char *errbuf = NULL;
if (!migrate) {
VIR_DEBUG("No OVS port data for interface %s", ifname);
return 0;
}
- cmd = virNetDevOpenvswitchCreateCmd();
+ cmd = virNetDevOpenvswitchCreateCmd(&errbuf);
virCommandAddArgList(cmd, "set", "Interface", ifname, NULL);
virCommandAddArgFormat(cmd, "external_ids:PortData=%s", migrate);
/* Run the command */
if (virCommandRun(cmd, NULL) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Unable to run command to set OVS port data for interface %1$s"),
- ifname);
+ _("Unable to run command to set OVS port data for interface %1$s: %2$s"),
+ ifname, NULLSTR(errbuf));
return -1;
}
virNetDevOpenvswitchInterfaceStats(const char *ifname,
virDomainInterfaceStatsPtr stats)
{
- g_autoptr(virCommand) cmd = virNetDevOpenvswitchCreateCmd();
+ g_autofree char *errbuf = NULL;
+ g_autoptr(virCommand) cmd = virNetDevOpenvswitchCreateCmd(&errbuf);
g_autofree char *output = NULL;
virCommandAddArgList(cmd, "--if-exists", "--format=list", "--data=json",
if (virCommandRun(cmd, NULL) < 0 ||
STREQ_NULLABLE(output, "")) {
/* no ovs-vsctl or interface 'ifname' doesn't exists in ovs */
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Interface not found"));
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Interface not found: %1$s"),
+ NULLSTR(errbuf));
return -1;
}
int
virNetDevOpenvswitchInterfaceGetMaster(const char *ifname, char **master)
{
- g_autoptr(virCommand) cmd = virNetDevOpenvswitchCreateCmd();
+ g_autofree char *errbuf = NULL;
+ g_autoptr(virCommand) cmd = virNetDevOpenvswitchCreateCmd(&errbuf);
int exitstatus;
*master = NULL;
if (virCommandRun(cmd, &exitstatus) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Unable to run command to get OVS master for interface %1$s"),
- ifname);
+ _("Unable to run command to get OVS master for interface %1$s: %2$s"),
+ ifname, NULLSTR(errbuf));
return -1;
}
return 0;
}
- cmd = virNetDevOpenvswitchCreateCmd();
+ cmd = virNetDevOpenvswitchCreateCmd(NULL);
if (server) {
virCommandAddArgList(cmd, "--no-headings", "--columns=name", "find",
int virNetDevOpenvswitchUpdateVlan(const char *ifname,
const virNetDevVlan *virtVlan)
{
- g_autoptr(virCommand) cmd = virNetDevOpenvswitchCreateCmd();
+ g_autofree char *errbuf = NULL;
+ g_autoptr(virCommand) cmd = virNetDevOpenvswitchCreateCmd(&errbuf);
virCommandAddArgList(cmd,
"--", "--if-exists", "clear", "Port", ifname, "tag",
if (virCommandRun(cmd, NULL) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Unable to set vlan configuration on port %1$s"), ifname);
+ _("Unable to set vlan configuration on port %1$s: %2$s"),
+ ifname, NULLSTR(errbuf));
return -1;
}
g_autoptr(virCommand) cmd = NULL;
char *uuid = NULL;
- cmd = virNetDevOpenvswitchCreateCmd();
+ cmd = virNetDevOpenvswitchCreateCmd(NULL);
virCommandAddArgList(cmd, "--no-heading", "--columns=_uuid", "find", table,
vmid_ex_id, ifname_ex_id, NULL);
virCommandSetOutputBuffer(cmd, &uuid);
if (!*line) {
continue;
}
- listcmd = virNetDevOpenvswitchCreateCmd();
+ listcmd = virNetDevOpenvswitchCreateCmd(NULL);
virCommandAddArgList(listcmd, "--no-heading", "--columns=_uuid", "--if-exists",
"list", "port", ifname, "qos", NULL);
virCommandSetOutputBuffer(listcmd, &port_qos);
VIR_WARN("Unable to remove port qos on port %s", ifname);
}
if (port_qos && *port_qos) {
- g_autoptr(virCommand) cmd = virNetDevOpenvswitchCreateCmd();
+ g_autoptr(virCommand) cmd = virNetDevOpenvswitchCreateCmd(NULL);
virCommandAddArgList(cmd, "remove", "port", ifname, "qos", line, NULL);
if (virCommandRun(cmd, NULL) < 0) {
VIR_WARN("Unable to remove port qos on port %s", ifname);
}
}
- destroycmd = virNetDevOpenvswitchCreateCmd();
+ destroycmd = virNetDevOpenvswitchCreateCmd(NULL);
virCommandAddArgList(destroycmd, "destroy", "qos", line, NULL);
if (virCommandRun(destroycmd, NULL) < 0) {
VIR_WARN("Unable to destroy qos on port %s", ifname);
continue;
}
- cmd = virNetDevOpenvswitchCreateCmd();
+ cmd = virNetDevOpenvswitchCreateCmd(NULL);
virCommandAddArgList(cmd, "destroy", "queue", line, NULL);
if (virCommandRun(cmd, NULL) < 0) {
VIR_WARN("Unable to destroy queue on port %s", ifname);
virNetDevOpenvswitchInterfaceClearRxQos(const char *ifname)
{
g_autoptr(virCommand) cmd = NULL;
+ g_autofree char *errbuf = NULL;
- cmd = virNetDevOpenvswitchCreateCmd();
+ cmd = virNetDevOpenvswitchCreateCmd(&errbuf);
virCommandAddArgList(cmd, "set", "Interface", ifname, NULL);
virCommandAddArgFormat(cmd, "ingress_policing_rate=%llu", 0llu);
virCommandAddArgFormat(cmd, "ingress_policing_burst=%llu", 0llu);
if (virCommandRun(cmd, NULL) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Unable to reset ingress on port %1$s"), ifname);
+ _("Unable to reset ingress on port %1$s: %2$s"),
+ ifname, NULLSTR(errbuf));
return -1;
}
{
char vmuuidstr[VIR_UUID_STRING_BUFLEN];
g_autoptr(virCommand) cmd = NULL;
+ g_autofree char *errbuf = NULL;
g_autofree char *vmid_ex_id = NULL;
g_autofree char *ifname_ex_id = NULL;
g_autofree char *average = NULL;
qos_uuid = virNetDevOpenvswitchFindUUID("qos", vmid_ex_id, ifname_ex_id);
/* create qos and set */
- cmd = virNetDevOpenvswitchCreateCmd();
+ cmd = virNetDevOpenvswitchCreateCmd(&errbuf);
if (queue_uuid && *queue_uuid) {
g_auto(GStrv) lines = g_strsplit(queue_uuid, "\n", 0);
virCommandAddArgList(cmd, "set", "queue", lines[0], NULL);
if (virCommandRun(cmd, NULL) < 0) {
if (queue_uuid && *queue_uuid) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Unable to set queue configuration on port %1$s"), ifname);
+ _("Unable to set queue configuration on port %1$s: %2$s"),
+ ifname, NULLSTR(errbuf));
} else {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Unable to create and set qos configuration on port %1$s"), ifname);
+ _("Unable to create and set qos configuration on port %1$s: %2$s"),
+ ifname, NULLSTR(errbuf));
}
return -1;
}
if (qos_uuid && *qos_uuid) {
g_auto(GStrv) lines = g_strsplit(qos_uuid, "\n", 0);
- g_autoptr(virCommand) qoscmd = virNetDevOpenvswitchCreateCmd();
+ g_autofree char *qoserrbuf = NULL;
+ g_autoptr(virCommand) qoscmd = virNetDevOpenvswitchCreateCmd(&qoserrbuf);
virCommandAddArgList(qoscmd, "set", "qos", lines[0], NULL);
virCommandAddArgFormat(qoscmd, "other_config:min-rate=%s", average);
virCommandAddArgList(qoscmd, vmid_ex_id, ifname_ex_id, NULL);
if (virCommandRun(qoscmd, NULL) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Unable to set qos configuration on port %1$s"), ifname);
+ _("Unable to set qos configuration on port %1$s: %2$s"),
+ ifname, NULLSTR(qoserrbuf));
return -1;
}
}
const virNetDevBandwidthRate *rx)
{
g_autoptr(virCommand) cmd = NULL;
+ g_autofree char *errbuf = NULL;
- cmd = virNetDevOpenvswitchCreateCmd();
+ cmd = virNetDevOpenvswitchCreateCmd(&errbuf);
virCommandAddArgList(cmd, "set", "Interface", ifname, NULL);
virCommandAddArgFormat(cmd, "ingress_policing_rate=%llu",
rx->average * VIR_NETDEV_RX_TO_OVS);
if (virCommandRun(cmd, NULL) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Unable to set vlan configuration on port %1$s"), ifname);
+ _("Unable to set vlan configuration on port %1$s: %2$s"),
+ ifname, NULLSTR(errbuf));
return -1;
}