mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
qemu: Introduce qemuBuildMemballoonCommandLine
Add new function to manage adding the memballoon device options to the command line removing that task from the mainline qemuBuildCommandLine. Also modify the qemuBuildMemballoonDevStr to use const virDomainDef instead of virDomainDefPtr. Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
d2108df57c
commit
00e47796a9
@ -3408,7 +3408,7 @@ qemuBuildWatchdogCommandLine(virCommandPtr cmd,
|
||||
|
||||
|
||||
char *
|
||||
qemuBuildMemballoonDevStr(virDomainDefPtr def,
|
||||
qemuBuildMemballoonDevStr(const virDomainDef *def,
|
||||
virDomainMemballoonDefPtr dev,
|
||||
virQEMUCapsPtr qemuCaps)
|
||||
{
|
||||
@ -3456,6 +3456,47 @@ qemuBuildMemballoonDevStr(virDomainDefPtr def,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuBuildMemballoonCommandLine(virCommandPtr cmd,
|
||||
const virDomainDef *def,
|
||||
virQEMUCapsPtr qemuCaps)
|
||||
{
|
||||
/* QEMU changed its default behavior to not include the virtio balloon
|
||||
* device. Explicitly request it to ensure it will be present.
|
||||
*
|
||||
* NB: Earlier we declared that VirtIO balloon will always be in
|
||||
* slot 0x3 on bus 0x0
|
||||
*/
|
||||
if (STREQLEN(def->os.machine, "s390-virtio", 10) &&
|
||||
virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_S390) && def->memballoon)
|
||||
def->memballoon->model = VIR_DOMAIN_MEMBALLOON_MODEL_NONE;
|
||||
|
||||
if (def->memballoon &&
|
||||
def->memballoon->model != VIR_DOMAIN_MEMBALLOON_MODEL_NONE) {
|
||||
if (def->memballoon->model != VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("Memory balloon device type '%s' is not supported by this version of qemu"),
|
||||
virDomainMemballoonModelTypeToString(def->memballoon->model));
|
||||
return -1;
|
||||
}
|
||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
|
||||
char *optstr;
|
||||
virCommandAddArg(cmd, "-device");
|
||||
|
||||
optstr = qemuBuildMemballoonDevStr(def, def->memballoon, qemuCaps);
|
||||
if (!optstr)
|
||||
return -1;
|
||||
virCommandAddArg(cmd, optstr);
|
||||
VIR_FREE(optstr);
|
||||
} else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BALLOON)) {
|
||||
virCommandAddArgList(cmd, "-balloon", "virtio", NULL);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
qemuBuildNVRAMDevStr(virDomainNVRAMDefPtr dev)
|
||||
{
|
||||
@ -9141,37 +9182,8 @@ qemuBuildCommandLine(virConnectPtr conn,
|
||||
if (migrateURI)
|
||||
virCommandAddArgList(cmd, "-incoming", migrateURI, NULL);
|
||||
|
||||
/* QEMU changed its default behavior to not include the virtio balloon
|
||||
* device. Explicitly request it to ensure it will be present.
|
||||
*
|
||||
* NB: Earlier we declared that VirtIO balloon will always be in
|
||||
* slot 0x3 on bus 0x0
|
||||
*/
|
||||
if (STREQLEN(def->os.machine, "s390-virtio", 10) &&
|
||||
virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_S390) && def->memballoon)
|
||||
def->memballoon->model = VIR_DOMAIN_MEMBALLOON_MODEL_NONE;
|
||||
|
||||
if (def->memballoon &&
|
||||
def->memballoon->model != VIR_DOMAIN_MEMBALLOON_MODEL_NONE) {
|
||||
if (def->memballoon->model != VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("Memory balloon device type '%s' is not supported by this version of qemu"),
|
||||
virDomainMemballoonModelTypeToString(def->memballoon->model));
|
||||
goto error;
|
||||
}
|
||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
|
||||
char *optstr;
|
||||
virCommandAddArg(cmd, "-device");
|
||||
|
||||
optstr = qemuBuildMemballoonDevStr(def, def->memballoon, qemuCaps);
|
||||
if (!optstr)
|
||||
goto error;
|
||||
virCommandAddArg(cmd, optstr);
|
||||
VIR_FREE(optstr);
|
||||
} else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BALLOON)) {
|
||||
virCommandAddArgList(cmd, "-balloon", "virtio", NULL);
|
||||
}
|
||||
}
|
||||
if (qemuBuildMemballoonCommandLine(cmd, def, qemuCaps) < 0)
|
||||
goto error;
|
||||
|
||||
for (i = 0; i < def->nrngs; i++) {
|
||||
virDomainRNGDefPtr rng = def->rngs[i];
|
||||
|
@ -130,7 +130,7 @@ char *qemuBuildControllerDevStr(const virDomainDef *domainDef,
|
||||
virQEMUCapsPtr qemuCaps,
|
||||
int *nusbcontroller);
|
||||
|
||||
char *qemuBuildMemballoonDevStr(virDomainDefPtr domainDef,
|
||||
char *qemuBuildMemballoonDevStr(const virDomainDef *domainDef,
|
||||
virDomainMemballoonDefPtr dev,
|
||||
virQEMUCapsPtr qemuCaps);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user