conf: Tweak HPT feature parsing and formatting
This doesn't seem very useful at the moment, but it will make sense once we introduce another HPT-related setting. The output XML is decoupled from the input XML in preparation of future changes as well; while doing so, we can shave a few lines off the latter. This commit is best viewed with 'git show -w'. Signed-off-by: Andrea Bolognani <abologna@redhat.com>
This commit is contained in:
parent
c2fef631ba
commit
15f9db5303
@ -27258,6 +27258,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
|
|||||||
const char *type = NULL;
|
const char *type = NULL;
|
||||||
int n;
|
int n;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
virBuffer attributeBuf = VIR_BUFFER_INITIALIZER;
|
||||||
virBuffer childrenBuf = VIR_BUFFER_INITIALIZER;
|
virBuffer childrenBuf = VIR_BUFFER_INITIALIZER;
|
||||||
char *netprefix = NULL;
|
char *netprefix = NULL;
|
||||||
|
|
||||||
@ -27773,12 +27774,21 @@ virDomainDefFormatInternal(virDomainDefPtr def,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_FEATURE_HPT:
|
case VIR_DOMAIN_FEATURE_HPT:
|
||||||
if (def->features[i] != VIR_TRISTATE_SWITCH_ON ||
|
if (def->features[i] != VIR_TRISTATE_SWITCH_ON)
|
||||||
def->hpt_resizing == VIR_DOMAIN_HPT_RESIZING_NONE)
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
virBufferAsprintf(buf, "<hpt resizing='%s'/>\n",
|
virBufferFreeAndReset(&attributeBuf);
|
||||||
virDomainHPTResizingTypeToString(def->hpt_resizing));
|
|
||||||
|
if (def->hpt_resizing != VIR_DOMAIN_HPT_RESIZING_NONE) {
|
||||||
|
virBufferAsprintf(&attributeBuf,
|
||||||
|
" resizing='%s'",
|
||||||
|
virDomainHPTResizingTypeToString(def->hpt_resizing));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (virXMLFormatElement(buf, "hpt",
|
||||||
|
&attributeBuf, NULL) < 0) {
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* coverity[dead_error_begin] */
|
/* coverity[dead_error_begin] */
|
||||||
@ -28040,6 +28050,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
|
|||||||
error:
|
error:
|
||||||
virBufferFreeAndReset(buf);
|
virBufferFreeAndReset(buf);
|
||||||
virBufferFreeAndReset(&childrenBuf);
|
virBufferFreeAndReset(&childrenBuf);
|
||||||
|
virBufferFreeAndReset(&attributeBuf);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7257,24 +7257,26 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (def->features[VIR_DOMAIN_FEATURE_HPT] == VIR_TRISTATE_SWITCH_ON) {
|
if (def->features[VIR_DOMAIN_FEATURE_HPT] == VIR_TRISTATE_SWITCH_ON) {
|
||||||
const char *str;
|
|
||||||
|
|
||||||
if (def->hpt_resizing != VIR_DOMAIN_HPT_RESIZING_NONE &&
|
if (def->hpt_resizing != VIR_DOMAIN_HPT_RESIZING_NONE) {
|
||||||
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT)) {
|
const char *str;
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
||||||
_("HTP resizing is not supported by this "
|
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT)) {
|
||||||
"QEMU binary"));
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
goto cleanup;
|
_("HTP resizing is not supported by this "
|
||||||
|
"QEMU binary"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
str = virDomainHPTResizingTypeToString(def->hpt_resizing);
|
||||||
|
if (!str) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("Invalid setting for HPT resizing"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
virBufferAsprintf(&buf, ",resize-hpt=%s", str);
|
||||||
}
|
}
|
||||||
|
|
||||||
str = virDomainHPTResizingTypeToString(def->hpt_resizing);
|
|
||||||
if (!str) {
|
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
||||||
_("Invalid setting for HPT resizing"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
virBufferAsprintf(&buf, ",resize-hpt=%s", str);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cpu && cpu->model &&
|
if (cpu && cpu->model &&
|
||||||
|
@ -2,27 +2,17 @@
|
|||||||
<name>guest</name>
|
<name>guest</name>
|
||||||
<uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
|
<uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
|
||||||
<memory unit='KiB'>524288</memory>
|
<memory unit='KiB'>524288</memory>
|
||||||
<currentMemory unit='KiB'>524288</currentMemory>
|
|
||||||
<vcpu placement='static'>1</vcpu>
|
<vcpu placement='static'>1</vcpu>
|
||||||
<os>
|
<os>
|
||||||
<type arch='ppc64' machine='pseries'>hvm</type>
|
<type arch='ppc64' machine='pseries'>hvm</type>
|
||||||
<boot dev='hd'/>
|
|
||||||
</os>
|
</os>
|
||||||
<features>
|
<features>
|
||||||
<hpt resizing='required'/>
|
<hpt resizing='required'/>
|
||||||
</features>
|
</features>
|
||||||
<clock offset='utc'/>
|
|
||||||
<on_poweroff>destroy</on_poweroff>
|
|
||||||
<on_reboot>restart</on_reboot>
|
|
||||||
<on_crash>destroy</on_crash>
|
|
||||||
<devices>
|
<devices>
|
||||||
<emulator>/usr/bin/qemu-system-ppc64</emulator>
|
<emulator>/usr/bin/qemu-system-ppc64</emulator>
|
||||||
<controller type='usb' index='0' model='none'/>
|
<controller type='pci' model='pci-root'/>
|
||||||
<controller type='pci' index='0' model='pci-root'>
|
<controller type='usb' model='none'/>
|
||||||
<model name='spapr-pci-host-bridge'/>
|
|
||||||
<target index='0'/>
|
|
||||||
</controller>
|
|
||||||
<memballoon model='none'/>
|
<memballoon model='none'/>
|
||||||
<panic model='pseries'/>
|
|
||||||
</devices>
|
</devices>
|
||||||
</domain>
|
</domain>
|
||||||
|
@ -1 +0,0 @@
|
|||||||
../qemuxml2argvdata/pseries-features.xml
|
|
28
tests/qemuxml2xmloutdata/pseries-features.xml
Normal file
28
tests/qemuxml2xmloutdata/pseries-features.xml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<domain type='qemu'>
|
||||||
|
<name>guest</name>
|
||||||
|
<uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
|
||||||
|
<memory unit='KiB'>524288</memory>
|
||||||
|
<currentMemory unit='KiB'>524288</currentMemory>
|
||||||
|
<vcpu placement='static'>1</vcpu>
|
||||||
|
<os>
|
||||||
|
<type arch='ppc64' machine='pseries'>hvm</type>
|
||||||
|
<boot dev='hd'/>
|
||||||
|
</os>
|
||||||
|
<features>
|
||||||
|
<hpt resizing='required'/>
|
||||||
|
</features>
|
||||||
|
<clock offset='utc'/>
|
||||||
|
<on_poweroff>destroy</on_poweroff>
|
||||||
|
<on_reboot>restart</on_reboot>
|
||||||
|
<on_crash>destroy</on_crash>
|
||||||
|
<devices>
|
||||||
|
<emulator>/usr/bin/qemu-system-ppc64</emulator>
|
||||||
|
<controller type='pci' index='0' model='pci-root'>
|
||||||
|
<model name='spapr-pci-host-bridge'/>
|
||||||
|
<target index='0'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='usb' index='0' model='none'/>
|
||||||
|
<memballoon model='none'/>
|
||||||
|
<panic model='pseries'/>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
Loading…
x
Reference in New Issue
Block a user