mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-09 14:35:25 +00:00
qemu: Introduce qemuBuildWatchdogCommandLine
Add new function to manage adding the watchdog device options to the command line removing that task from the mainline qemuBuildCommandLine. Also since qemuBuildWatchdogDevStr was only local here, make it static as well as modifying the const virDomainDef. Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
1a91ddb496
commit
4666b762b9
@ -3329,8 +3329,8 @@ qemuBuildHostNetStr(virDomainNetDefPtr net,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char *
|
static char *
|
||||||
qemuBuildWatchdogDevStr(virDomainDefPtr def,
|
qemuBuildWatchdogDevStr(const virDomainDef *def,
|
||||||
virDomainWatchdogDefPtr dev,
|
virDomainWatchdogDefPtr dev,
|
||||||
virQEMUCapsPtr qemuCaps)
|
virQEMUCapsPtr qemuCaps)
|
||||||
{
|
{
|
||||||
@ -3358,6 +3358,55 @@ qemuBuildWatchdogDevStr(virDomainDefPtr def,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuBuildWatchdogCommandLine(virCommandPtr cmd,
|
||||||
|
const virDomainDef *def,
|
||||||
|
virQEMUCapsPtr qemuCaps)
|
||||||
|
{
|
||||||
|
virDomainWatchdogDefPtr watchdog = def->watchdog;
|
||||||
|
char *optstr;
|
||||||
|
const char *action;
|
||||||
|
|
||||||
|
if (!def->watchdog)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
|
||||||
|
virCommandAddArg(cmd, "-device");
|
||||||
|
|
||||||
|
optstr = qemuBuildWatchdogDevStr(def, watchdog, qemuCaps);
|
||||||
|
if (!optstr)
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
virCommandAddArg(cmd, "-watchdog");
|
||||||
|
|
||||||
|
const char *model = virDomainWatchdogModelTypeToString(watchdog->model);
|
||||||
|
if (!model) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
"%s", _("missing watchdog model"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (VIR_STRDUP(optstr, model) < 0)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
virCommandAddArg(cmd, optstr);
|
||||||
|
VIR_FREE(optstr);
|
||||||
|
|
||||||
|
if (watchdog->action == VIR_DOMAIN_WATCHDOG_ACTION_DUMP)
|
||||||
|
watchdog->action = VIR_DOMAIN_WATCHDOG_ACTION_PAUSE;
|
||||||
|
|
||||||
|
action = virDomainWatchdogActionTypeToString(watchdog->action);
|
||||||
|
if (!action) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
"%s", _("invalid watchdog action"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
virCommandAddArgList(cmd, "-watchdog-action", action, NULL);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
qemuBuildMemballoonDevStr(virDomainDefPtr def,
|
qemuBuildMemballoonDevStr(virDomainDefPtr def,
|
||||||
virDomainMemballoonDefPtr dev,
|
virDomainMemballoonDefPtr dev,
|
||||||
@ -8863,44 +8912,8 @@ qemuBuildCommandLine(virConnectPtr conn,
|
|||||||
if (qemuBuildSoundCommandLine(cmd, def, qemuCaps) < 0)
|
if (qemuBuildSoundCommandLine(cmd, def, qemuCaps) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
/* Add watchdog hardware */
|
if (qemuBuildWatchdogCommandLine(cmd, def, qemuCaps) < 0)
|
||||||
if (def->watchdog) {
|
goto error;
|
||||||
virDomainWatchdogDefPtr watchdog = def->watchdog;
|
|
||||||
char *optstr;
|
|
||||||
|
|
||||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
|
|
||||||
virCommandAddArg(cmd, "-device");
|
|
||||||
|
|
||||||
optstr = qemuBuildWatchdogDevStr(def, watchdog, qemuCaps);
|
|
||||||
if (!optstr)
|
|
||||||
goto error;
|
|
||||||
} else {
|
|
||||||
virCommandAddArg(cmd, "-watchdog");
|
|
||||||
|
|
||||||
const char *model = virDomainWatchdogModelTypeToString(watchdog->model);
|
|
||||||
if (!model) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
"%s", _("missing watchdog model"));
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (VIR_STRDUP(optstr, model) < 0)
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
virCommandAddArg(cmd, optstr);
|
|
||||||
VIR_FREE(optstr);
|
|
||||||
|
|
||||||
int act = watchdog->action;
|
|
||||||
if (act == VIR_DOMAIN_WATCHDOG_ACTION_DUMP)
|
|
||||||
act = VIR_DOMAIN_WATCHDOG_ACTION_PAUSE;
|
|
||||||
const char *action = virDomainWatchdogActionTypeToString(act);
|
|
||||||
if (!action) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
"%s", _("invalid watchdog action"));
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
virCommandAddArgList(cmd, "-watchdog-action", action, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Add redirected devices */
|
/* Add redirected devices */
|
||||||
for (i = 0; i < def->nredirdevs; i++) {
|
for (i = 0; i < def->nredirdevs; i++) {
|
||||||
|
@ -130,10 +130,6 @@ char *qemuBuildControllerDevStr(const virDomainDef *domainDef,
|
|||||||
virQEMUCapsPtr qemuCaps,
|
virQEMUCapsPtr qemuCaps,
|
||||||
int *nusbcontroller);
|
int *nusbcontroller);
|
||||||
|
|
||||||
char *qemuBuildWatchdogDevStr(virDomainDefPtr domainDef,
|
|
||||||
virDomainWatchdogDefPtr dev,
|
|
||||||
virQEMUCapsPtr qemuCaps);
|
|
||||||
|
|
||||||
char *qemuBuildMemballoonDevStr(virDomainDefPtr domainDef,
|
char *qemuBuildMemballoonDevStr(virDomainDefPtr domainDef,
|
||||||
virDomainMemballoonDefPtr dev,
|
virDomainMemballoonDefPtr dev,
|
||||||
virQEMUCapsPtr qemuCaps);
|
virQEMUCapsPtr qemuCaps);
|
||||||
|
Loading…
Reference in New Issue
Block a user