mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
qemu: forbid setting guest-side IP address/route info of <interface>
libvirt's qemu driver doesn't have direct access to the config on the guest side of a network interface, and currently doesn't have any method in place to even inform the guest of the desired config. In the future, an unenforceable attempt to set the guest-side IP info could be made by adding a static host entry to the appropriate dnsmasq configuration (or changing the default dhcp client address on the qemu commandline for type='user' interfaces), or enhancing the guest agent to allow setting an IP address, but for now it can't have any effect, and we don't want to give the illusion that it does. To prevent the "disappearance" of any existing configs with ip address/route info (due to parser failure), this check is added in the newly implemented qemuDomainDeviceDefValidate(), which is only called when a domain is defined or started, *not* when it is reread from disk at libvirtd startup.
This commit is contained in:
parent
fbc1843d2e
commit
d987f63a45
@ -2190,6 +2190,38 @@ qemuDomainDefValidate(const virDomainDef *def,
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
|
||||
const virDomainDef *def ATTRIBUTE_UNUSED,
|
||||
void *opaque)
|
||||
{
|
||||
virQEMUDriverPtr driver = opaque;
|
||||
virQEMUCapsPtr qemuCaps = NULL;
|
||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||
int ret = -1;
|
||||
|
||||
qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache, def->emulator);
|
||||
|
||||
if (dev->type == VIR_DOMAIN_DEVICE_NET) {
|
||||
const virDomainNetDef *net = dev->data.net;
|
||||
|
||||
if (net->guestIP.nroutes || net->guestIP.nips) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("Invalid attempt to set network interface "
|
||||
"guest-side IP route and/or address info, "
|
||||
"not supported by QEMU"));
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
virObjectUnref(qemuCaps);
|
||||
virObjectUnref(cfg);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static const char *
|
||||
qemuDomainDefaultNetModel(const virDomainDef *def,
|
||||
virQEMUCapsPtr qemuCaps)
|
||||
@ -2442,6 +2474,8 @@ virDomainDefParserConfig virQEMUDriverDomainDefParserConfig = {
|
||||
.domainPostParseCallback = qemuDomainDefPostParse,
|
||||
.assignAddressesCallback = qemuDomainDefAssignAddresses,
|
||||
.domainValidateCallback = qemuDomainDefValidate,
|
||||
.deviceValidateCallback = qemuDomainDeviceDefValidate,
|
||||
|
||||
.features = VIR_DOMAIN_DEF_FEATURE_MEMORY_HOTPLUG |
|
||||
VIR_DOMAIN_DEF_FEATURE_OFFLINE_VCPUPIN
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user