提交 4028d7a4 编写于 作者: A Andrea Bolognani

qemu: Move functions around

Make sure related functions, eg. all qemuDomainIs*(), are
close together instead of being sprinkled throughout both
the header and implementation file, and also that all
qemuDomainMachine*() functions are declared first since
we're going to make a bunch of them static later on.
Signed-off-by: NAndrea Bolognani <abologna@redhat.com>
上级 616beb17
...@@ -9875,13 +9875,6 @@ qemuFindAgentConfig(virDomainDefPtr def) ...@@ -9875,13 +9875,6 @@ qemuFindAgentConfig(virDomainDefPtr def)
} }
bool
qemuDomainIsQ35(const virDomainDef *def)
{
return qemuDomainMachineIsQ35(def->os.machine);
}
bool bool
qemuDomainMachineIsQ35(const char *machine) qemuDomainMachineIsQ35(const char *machine)
{ {
...@@ -9890,13 +9883,6 @@ qemuDomainMachineIsQ35(const char *machine) ...@@ -9890,13 +9883,6 @@ qemuDomainMachineIsQ35(const char *machine)
} }
bool
qemuDomainIsI440FX(const virDomainDef *def)
{
return qemuDomainMachineIsI440FX(def->os.machine);
}
bool bool
qemuDomainMachineIsI440FX(const char *machine) qemuDomainMachineIsI440FX(const char *machine)
{ {
...@@ -9909,14 +9895,23 @@ qemuDomainMachineIsI440FX(const char *machine) ...@@ -9909,14 +9895,23 @@ qemuDomainMachineIsI440FX(const char *machine)
bool bool
qemuDomainHasPCIRoot(const virDomainDef *def) qemuDomainMachineIsS390CCW(const char *machine)
{ {
int root = virDomainControllerFind(def, VIR_DOMAIN_CONTROLLER_TYPE_PCI, 0); return STRPREFIX(machine, "s390-ccw");
}
if (root < 0)
bool
qemuDomainMachineIsARMVirt(const char *machine,
const virArch arch)
{
if (arch != VIR_ARCH_ARMV6L &&
arch != VIR_ARCH_ARMV7L &&
arch != VIR_ARCH_AARCH64)
return false; return false;
if (def->controllers[root]->model != VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT) if (STRNEQ(machine, "virt") &&
!STRPREFIX(machine, "virt-"))
return false; return false;
return true; return true;
...@@ -9924,14 +9919,29 @@ qemuDomainHasPCIRoot(const virDomainDef *def) ...@@ -9924,14 +9919,29 @@ qemuDomainHasPCIRoot(const virDomainDef *def)
bool bool
qemuDomainHasPCIeRoot(const virDomainDef *def) qemuDomainMachineIsRISCVVirt(const char *machine,
const virArch arch)
{ {
int root = virDomainControllerFind(def, VIR_DOMAIN_CONTROLLER_TYPE_PCI, 0); if (!ARCH_IS_RISCV(arch))
return false;
if (root < 0) if (STRNEQ(machine, "virt") &&
!STRPREFIX(machine, "virt-"))
return false; return false;
if (def->controllers[root]->model != VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT) return true;
}
bool
qemuDomainMachineIsPSeries(const char *machine,
const virArch arch)
{
if (!ARCH_IS_PPC64(arch))
return false;
if (STRNEQ(machine, "pseries") &&
!STRPREFIX(machine, "pseries-"))
return false; return false;
return true; return true;
...@@ -9939,9 +9949,12 @@ qemuDomainHasPCIeRoot(const virDomainDef *def) ...@@ -9939,9 +9949,12 @@ qemuDomainHasPCIeRoot(const virDomainDef *def)
bool bool
qemuDomainNeedsFDC(const virDomainDef *def) qemuDomainMachineHasBuiltinIDE(const char *machine)
{ {
return qemuDomainMachineNeedsFDC(def->os.machine); return qemuDomainMachineIsI440FX(machine) ||
STREQ(machine, "malta") ||
STREQ(machine, "sun4u") ||
STREQ(machine, "g3beige");
} }
...@@ -9964,40 +9977,30 @@ qemuDomainMachineNeedsFDC(const char *machine) ...@@ -9964,40 +9977,30 @@ qemuDomainMachineNeedsFDC(const char *machine)
bool bool
qemuDomainIsS390CCW(const virDomainDef *def) qemuDomainIsQ35(const virDomainDef *def)
{ {
return qemuDomainMachineIsS390CCW(def->os.machine); return qemuDomainMachineIsQ35(def->os.machine);
} }
bool bool
qemuDomainMachineIsS390CCW(const char *machine) qemuDomainIsI440FX(const virDomainDef *def)
{ {
return STRPREFIX(machine, "s390-ccw"); return qemuDomainMachineIsI440FX(def->os.machine);
} }
bool bool
qemuDomainIsARMVirt(const virDomainDef *def) qemuDomainIsS390CCW(const virDomainDef *def)
{ {
return qemuDomainMachineIsARMVirt(def->os.machine, def->os.arch); return qemuDomainMachineIsS390CCW(def->os.machine);
} }
bool bool
qemuDomainMachineIsARMVirt(const char *machine, qemuDomainIsARMVirt(const virDomainDef *def)
const virArch arch)
{ {
if (arch != VIR_ARCH_ARMV6L && return qemuDomainMachineIsARMVirt(def->os.machine, def->os.arch);
arch != VIR_ARCH_ARMV7L &&
arch != VIR_ARCH_AARCH64)
return false;
if (STRNEQ(machine, "virt") &&
!STRPREFIX(machine, "virt-"))
return false;
return true;
} }
...@@ -10009,14 +10012,21 @@ qemuDomainIsRISCVVirt(const virDomainDef *def) ...@@ -10009,14 +10012,21 @@ qemuDomainIsRISCVVirt(const virDomainDef *def)
bool bool
qemuDomainMachineIsRISCVVirt(const char *machine, qemuDomainIsPSeries(const virDomainDef *def)
const virArch arch)
{ {
if (!ARCH_IS_RISCV(arch)) return qemuDomainMachineIsPSeries(def->os.machine, def->os.arch);
}
bool
qemuDomainHasPCIRoot(const virDomainDef *def)
{
int root = virDomainControllerFind(def, VIR_DOMAIN_CONTROLLER_TYPE_PCI, 0);
if (root < 0)
return false; return false;
if (STRNEQ(machine, "virt") && if (def->controllers[root]->model != VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT)
!STRPREFIX(machine, "virt-"))
return false; return false;
return true; return true;
...@@ -10024,24 +10034,31 @@ qemuDomainMachineIsRISCVVirt(const char *machine, ...@@ -10024,24 +10034,31 @@ qemuDomainMachineIsRISCVVirt(const char *machine,
bool bool
qemuDomainIsPSeries(const virDomainDef *def) qemuDomainHasPCIeRoot(const virDomainDef *def)
{ {
return qemuDomainMachineIsPSeries(def->os.machine, def->os.arch); int root = virDomainControllerFind(def, VIR_DOMAIN_CONTROLLER_TYPE_PCI, 0);
if (root < 0)
return false;
if (def->controllers[root]->model != VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT)
return false;
return true;
} }
bool bool
qemuDomainMachineIsPSeries(const char *machine, qemuDomainHasBuiltinIDE(const virDomainDef *def)
const virArch arch)
{ {
if (!ARCH_IS_PPC64(arch)) return qemuDomainMachineHasBuiltinIDE(def->os.machine);
return false; }
if (STRNEQ(machine, "pseries") &&
!STRPREFIX(machine, "pseries-"))
return false;
return true; bool
qemuDomainNeedsFDC(const virDomainDef *def)
{
return qemuDomainMachineNeedsFDC(def->os.machine);
} }
...@@ -10239,23 +10256,6 @@ qemuDomainDefValidateMemoryHotplug(const virDomainDef *def, ...@@ -10239,23 +10256,6 @@ qemuDomainDefValidateMemoryHotplug(const virDomainDef *def,
} }
bool
qemuDomainHasBuiltinIDE(const virDomainDef *def)
{
return qemuDomainMachineHasBuiltinIDE(def->os.machine);
}
bool
qemuDomainMachineHasBuiltinIDE(const char *machine)
{
return qemuDomainMachineIsI440FX(machine) ||
STREQ(machine, "malta") ||
STREQ(machine, "sun4u") ||
STREQ(machine, "g3beige");
}
/** /**
* qemuDomainUpdateCurrentMemorySize: * qemuDomainUpdateCurrentMemorySize:
* *
......
...@@ -828,20 +828,8 @@ void qemuDomainMemoryDeviceAlignSize(virDomainDefPtr def, ...@@ -828,20 +828,8 @@ void qemuDomainMemoryDeviceAlignSize(virDomainDefPtr def,
virDomainChrDefPtr qemuFindAgentConfig(virDomainDefPtr def); virDomainChrDefPtr qemuFindAgentConfig(virDomainDefPtr def);
bool qemuDomainIsQ35(const virDomainDef *def);
bool qemuDomainIsI440FX(const virDomainDef *def);
bool qemuDomainHasPCIRoot(const virDomainDef *def);
bool qemuDomainHasPCIeRoot(const virDomainDef *def);
bool qemuDomainNeedsFDC(const virDomainDef *def);
bool qemuDomainIsS390CCW(const virDomainDef *def);
bool qemuDomainIsARMVirt(const virDomainDef *def);
bool qemuDomainIsRISCVVirt(const virDomainDef *def);
bool qemuDomainIsPSeries(const virDomainDef *def);
bool qemuDomainHasBuiltinIDE(const virDomainDef *def);
bool qemuDomainMachineIsQ35(const char *machine); bool qemuDomainMachineIsQ35(const char *machine);
bool qemuDomainMachineIsI440FX(const char *machine); bool qemuDomainMachineIsI440FX(const char *machine);
bool qemuDomainMachineNeedsFDC(const char *machine);
bool qemuDomainMachineIsS390CCW(const char *machine); bool qemuDomainMachineIsS390CCW(const char *machine);
bool qemuDomainMachineIsARMVirt(const char *machine, bool qemuDomainMachineIsARMVirt(const char *machine,
const virArch arch); const virArch arch);
...@@ -850,6 +838,18 @@ bool qemuDomainMachineIsRISCVVirt(const char *machine, ...@@ -850,6 +838,18 @@ bool qemuDomainMachineIsRISCVVirt(const char *machine,
bool qemuDomainMachineIsPSeries(const char *machine, bool qemuDomainMachineIsPSeries(const char *machine,
const virArch arch); const virArch arch);
bool qemuDomainMachineHasBuiltinIDE(const char *machine); bool qemuDomainMachineHasBuiltinIDE(const char *machine);
bool qemuDomainMachineNeedsFDC(const char *machine);
bool qemuDomainIsQ35(const virDomainDef *def);
bool qemuDomainIsI440FX(const virDomainDef *def);
bool qemuDomainIsS390CCW(const virDomainDef *def);
bool qemuDomainIsARMVirt(const virDomainDef *def);
bool qemuDomainIsRISCVVirt(const virDomainDef *def);
bool qemuDomainIsPSeries(const virDomainDef *def);
bool qemuDomainHasPCIRoot(const virDomainDef *def);
bool qemuDomainHasPCIeRoot(const virDomainDef *def);
bool qemuDomainHasBuiltinIDE(const virDomainDef *def);
bool qemuDomainNeedsFDC(const virDomainDef *def);
void qemuDomainUpdateCurrentMemorySize(virDomainObjPtr vm); void qemuDomainUpdateCurrentMemorySize(virDomainObjPtr vm);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册