mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-21 19:02:25 +00:00
qemu_command.c: move 'panic' validation to qemu_validate.c
Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
parent
d3dad77dd6
commit
0bf8dfb02a
@ -9325,78 +9325,13 @@ qemuBuildVMCoreInfoCommandLine(virCommandPtr cmd,
|
||||
|
||||
static int
|
||||
qemuBuildPanicCommandLine(virCommandPtr cmd,
|
||||
const virDomainDef *def,
|
||||
virQEMUCapsPtr qemuCaps)
|
||||
const virDomainDef *def)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < def->npanics; i++) {
|
||||
switch ((virDomainPanicModel) def->panics[i]->model) {
|
||||
case VIR_DOMAIN_PANIC_MODEL_S390:
|
||||
/* For s390 guests, the hardware provides the same
|
||||
* functionality as the pvpanic device. The address
|
||||
* cannot be configured by the user */
|
||||
if (!ARCH_IS_S390(def->os.arch)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("only S390 guests support "
|
||||
"panic device of model 's390'"));
|
||||
return -1;
|
||||
}
|
||||
if (def->panics[i]->info.type !=
|
||||
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("setting the panic device address is not "
|
||||
"supported for model 's390'"));
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_PANIC_MODEL_HYPERV:
|
||||
/* Panic with model 'hyperv' is not a device, it should
|
||||
* be configured in cpu commandline. The address
|
||||
* cannot be configured by the user */
|
||||
if (!ARCH_IS_X86(def->os.arch)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("only i686 and x86_64 guests support "
|
||||
"panic device of model 'hyperv'"));
|
||||
return -1;
|
||||
}
|
||||
if (def->panics[i]->info.type !=
|
||||
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("setting the panic device address is not "
|
||||
"supported for model 'hyperv'"));
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_PANIC_MODEL_PSERIES:
|
||||
/* For pSeries guests, the firmware provides the same
|
||||
* functionality as the pvpanic device. The address
|
||||
* cannot be configured by the user */
|
||||
if (!qemuDomainIsPSeries(def)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("only pSeries guests support panic device "
|
||||
"of model 'pseries'"));
|
||||
return -1;
|
||||
}
|
||||
if (def->panics[i]->info.type !=
|
||||
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("setting the panic device address is not "
|
||||
"supported for model 'pseries'"));
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_PANIC_MODEL_ISA:
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PANIC)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("the QEMU binary does not support the "
|
||||
"ISA panic device"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (def->panics[i]->info.type) {
|
||||
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA:
|
||||
virCommandAddArg(cmd, "-device");
|
||||
@ -9407,14 +9342,11 @@ qemuBuildPanicCommandLine(virCommandPtr cmd,
|
||||
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE:
|
||||
virCommandAddArgList(cmd, "-device", "pvpanic", NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("panic is supported only "
|
||||
"with ISA address type"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
case VIR_DOMAIN_PANIC_MODEL_S390:
|
||||
case VIR_DOMAIN_PANIC_MODEL_HYPERV:
|
||||
case VIR_DOMAIN_PANIC_MODEL_PSERIES:
|
||||
/* default model value was changed before in post parse */
|
||||
case VIR_DOMAIN_PANIC_MODEL_DEFAULT:
|
||||
case VIR_DOMAIN_PANIC_MODEL_LAST:
|
||||
@ -10017,7 +9949,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
|
||||
if (qemuBuildSeccompSandboxCommandLine(cmd, cfg, qemuCaps) < 0)
|
||||
return NULL;
|
||||
|
||||
if (qemuBuildPanicCommandLine(cmd, def, qemuCaps) < 0)
|
||||
if (qemuBuildPanicCommandLine(cmd, def) < 0)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < def->nshmems; i++) {
|
||||
|
@ -878,6 +878,99 @@ qemuValidateDomainDefSysinfo(const virSysinfoDef *def,
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuValidateDomainDefPanic(const virDomainDef *def,
|
||||
virQEMUCapsPtr qemuCaps)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < def->npanics; i++) {
|
||||
switch ((virDomainPanicModel) def->panics[i]->model) {
|
||||
case VIR_DOMAIN_PANIC_MODEL_S390:
|
||||
/* For s390 guests, the hardware provides the same
|
||||
* functionality as the pvpanic device. The address
|
||||
* cannot be configured by the user */
|
||||
if (!ARCH_IS_S390(def->os.arch)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("only S390 guests support "
|
||||
"panic device of model 's390'"));
|
||||
return -1;
|
||||
}
|
||||
if (def->panics[i]->info.type !=
|
||||
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("setting the panic device address is not "
|
||||
"supported for model 's390'"));
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_PANIC_MODEL_HYPERV:
|
||||
/* Panic with model 'hyperv' is not a device, it should
|
||||
* be configured in cpu commandline. The address
|
||||
* cannot be configured by the user */
|
||||
if (!ARCH_IS_X86(def->os.arch)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("only i686 and x86_64 guests support "
|
||||
"panic device of model 'hyperv'"));
|
||||
return -1;
|
||||
}
|
||||
if (def->panics[i]->info.type !=
|
||||
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("setting the panic device address is not "
|
||||
"supported for model 'hyperv'"));
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_PANIC_MODEL_PSERIES:
|
||||
/* For pSeries guests, the firmware provides the same
|
||||
* functionality as the pvpanic device. The address
|
||||
* cannot be configured by the user */
|
||||
if (!qemuDomainIsPSeries(def)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("only pSeries guests support panic device "
|
||||
"of model 'pseries'"));
|
||||
return -1;
|
||||
}
|
||||
if (def->panics[i]->info.type !=
|
||||
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("setting the panic device address is not "
|
||||
"supported for model 'pseries'"));
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_PANIC_MODEL_ISA:
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PANIC)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("the QEMU binary does not support the "
|
||||
"ISA panic device"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (def->panics[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
|
||||
def->panics[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("panic is supported only "
|
||||
"with ISA address type"));
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
/* default model value was changed before in post parse */
|
||||
case VIR_DOMAIN_PANIC_MODEL_DEFAULT:
|
||||
case VIR_DOMAIN_PANIC_MODEL_LAST:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qemuValidateDomainDef(const virDomainDef *def,
|
||||
void *opaque)
|
||||
@ -1112,6 +1205,9 @@ qemuValidateDomainDef(const virDomainDef *def,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (qemuValidateDomainDefPanic(def, qemuCaps) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1 +1 @@
|
||||
unsupported configuration: 'spapr-vty' is not supported in this QEMU binary
|
||||
unsupported configuration: setting the panic device address is not supported for model 'pseries'
|
||||
|
@ -2065,8 +2065,8 @@ mymain(void)
|
||||
DO_TEST("pseries-panic-no-address",
|
||||
QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
|
||||
QEMU_CAPS_DEVICE_SPAPR_VTY);
|
||||
DO_TEST_FAILURE("pseries-panic-address",
|
||||
QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
|
||||
DO_TEST_PARSE_ERROR("pseries-panic-address",
|
||||
QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
|
||||
|
||||
DO_TEST("pseries-phb-simple",
|
||||
QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
|
||||
@ -2378,9 +2378,9 @@ mymain(void)
|
||||
DO_TEST("s390-panic-no-address",
|
||||
QEMU_CAPS_CCW,
|
||||
QEMU_CAPS_VIRTIO_S390);
|
||||
DO_TEST_FAILURE("s390-panic-address",
|
||||
QEMU_CAPS_CCW,
|
||||
QEMU_CAPS_VIRTIO_S390);
|
||||
DO_TEST_PARSE_ERROR("s390-panic-address",
|
||||
QEMU_CAPS_CCW,
|
||||
QEMU_CAPS_VIRTIO_S390);
|
||||
DO_TEST("s390-panic-missing",
|
||||
QEMU_CAPS_CCW,
|
||||
QEMU_CAPS_VIRTIO_S390);
|
||||
|
@ -1116,12 +1116,12 @@ mymain(void)
|
||||
QEMU_CAPS_DEVICE_QXL,
|
||||
QEMU_CAPS_Q35_PCI_HOLE64_SIZE);
|
||||
|
||||
DO_TEST("panic", NONE);
|
||||
DO_TEST("panic-isa", NONE);
|
||||
DO_TEST("panic", QEMU_CAPS_DEVICE_PANIC);
|
||||
DO_TEST("panic-isa", QEMU_CAPS_DEVICE_PANIC);
|
||||
DO_TEST("panic-pseries",
|
||||
QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
|
||||
DO_TEST("panic-double", NONE);
|
||||
DO_TEST("panic-no-address", NONE);
|
||||
DO_TEST("panic-double", QEMU_CAPS_DEVICE_PANIC);
|
||||
DO_TEST("panic-no-address", QEMU_CAPS_DEVICE_PANIC);
|
||||
|
||||
DO_TEST("disk-backing-chains", NONE);
|
||||
DO_TEST("disk-backing-chains-index", NONE);
|
||||
|
Loading…
x
Reference in New Issue
Block a user