virCommandPtr
nodeDeviceGetMdevctlStartCommand(virNodeDeviceDefPtr def,
- char **uuid_out)
+ char **uuid_out,
+ char **errmsg)
{
virCommandPtr cmd;
g_autofree char *json = NULL;
virCommandSetInputBuffer(cmd, json);
virCommandSetOutputBuffer(cmd, uuid_out);
+ virCommandSetErrorBuffer(cmd, errmsg);
return cmd;
}
static int
-virMdevctlStart(virNodeDeviceDefPtr def, char **uuid)
+virMdevctlStart(virNodeDeviceDefPtr def, char **uuid, char **errmsg)
{
int status;
- g_autoptr(virCommand) cmd = nodeDeviceGetMdevctlStartCommand(def, uuid);
+ g_autoptr(virCommand) cmd = nodeDeviceGetMdevctlStartCommand(def, uuid,
+ errmsg);
if (!cmd)
return -1;
virNodeDeviceDefPtr def)
{
g_autofree char *uuid = NULL;
+ g_autofree char *errmsg = NULL;
if (!def->parent) {
virReportError(VIR_ERR_XML_ERROR, "%s",
return NULL;
}
- if (virMdevctlStart(def, &uuid) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Unable to start mediated device"));
+ if (virMdevctlStart(def, &uuid, &errmsg) < 0) {
+ if (errmsg)
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unable to start mediated device '%s': %s"),
+ def->name, errmsg);
return NULL;
}
virCommandPtr
-nodeDeviceGetMdevctlStopCommand(const char *uuid)
-{
- return virCommandNewArgList(MDEVCTL,
- "stop",
- "-u",
- uuid,
- NULL);
+nodeDeviceGetMdevctlStopCommand(const char *uuid, char **errmsg)
+{
+ virCommandPtr cmd = virCommandNewArgList(MDEVCTL,
+ "stop",
+ "-u",
+ uuid,
+ NULL);
+ virCommandSetErrorBuffer(cmd, errmsg);
+ return cmd;
}
static int
-virMdevctlStop(virNodeDeviceDefPtr def)
+virMdevctlStop(virNodeDeviceDefPtr def, char **errmsg)
{
int status;
g_autoptr(virCommand) cmd = NULL;
- cmd = nodeDeviceGetMdevctlStopCommand(def->caps->data.mdev.uuid);
+ cmd = nodeDeviceGetMdevctlStopCommand(def->caps->data.mdev.uuid, errmsg);
if (virCommandRun(cmd, &status) < 0 || status != 0)
return -1;
ret = 0;
} else if (nodeDeviceHasCapability(def, VIR_NODE_DEV_CAP_MDEV)) {
- if (virMdevctlStop(def) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Unable to stop mediated device"));
+ g_autofree char *errmsg = NULL;
+
+ if (virMdevctlStop(def, &errmsg) < 0) {
+ if (errmsg)
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unable to destroy '%s': %s"), def->name,
+ errmsg);
goto cleanup;
}
ret = 0;
const char *actualCmdline = NULL;
int ret = -1;
g_autofree char *uuid = NULL;
+ g_autofree char *errmsg = NULL;
g_autofree char *stdinbuf = NULL;
g_autoptr(virCommand) cmd = NULL;
/* this function will set a stdin buffer containing the json configuration
* of the device. The json value is captured in the callback above */
- cmd = nodeDeviceGetMdevctlStartCommand(def, &uuid);
+ cmd = nodeDeviceGetMdevctlStartCommand(def, &uuid, &errmsg);
if (!cmd)
goto cleanup;
const char *actualCmdline = NULL;
int ret = -1;
g_autoptr(virCommand) cmd = NULL;
+ g_autofree char *errmsg = NULL;
g_autofree char *cmdlinefile =
g_strdup_printf("%s/nodedevmdevctldata/mdevctl-stop.argv",
abs_srcdir);
- cmd = nodeDeviceGetMdevctlStopCommand(uuid);
+ cmd = nodeDeviceGetMdevctlStopCommand(uuid, &errmsg);
if (!cmd)
goto cleanup;