mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-05 12:35:20 +00:00
conf: Use correct type for balloon stats period
We're parsing memballoon status period as unsigned int, but when we're
trying to set it, both we and qemu use signed int. That means large
values will get wrapped around to negative one resulting in error.
Basically the same problem as commit e3a7b874
was dealing with when
updating live domain.
QEMU changed the accepted value to int64 in commit 1f9296b5, but even
values as INT_MAX don't make sense since the value passed means seconds.
Hence adding capability flag for this change isn't worth it.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1140958
Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
4fca30e0bd
commit
ad69e8be4a
@ -5618,18 +5618,17 @@ qemu-kvm -net nic,model=? /dev/null
|
|||||||
<dt><code>period</code></dt>
|
<dt><code>period</code></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<p>
|
<p>
|
||||||
The optional <code>period</code> allows the QEMU virtio memory
|
The optional <code>period</code> allows the QEMU virtio memory balloon
|
||||||
balloon driver to provide statistics through the <code>virsh
|
driver to provide statistics through the <code>virsh dommemstat
|
||||||
dommemstat [domain]</code> command. By default, collection is
|
[domain]</code> command. By default, collection is not enabled. In
|
||||||
not enabled. In order to enable, use the <code>virsh dommemstat
|
order to enable, use the <code>virsh dommemstat [domain] --period
|
||||||
[domain] --period [number]</code> command or <code>virsh edit</code>
|
[number]</code> command or <code>virsh edit</code> command to add the
|
||||||
command to add the option to the XML definition.
|
option to the XML definition. The <code>virsh dommemstat</code> will
|
||||||
The <code>virsh dommemstat</code> will accept the options
|
accept the options <code>--live</code>, <code>--current</code>,
|
||||||
<code>--live</code>, <code>--current</code>, or <code>--config</code>.
|
or <code>--config</code>. If an option is not provided, the change
|
||||||
If an option is not provided, the change for a running domain will
|
for a running domain will only be made to the active guest. If the
|
||||||
only be made to the active guest.
|
QEMU driver is not at the right revision, the attempt to set the
|
||||||
If the QEMU driver is not at the right
|
period will fail. Large values (e.g. many years) might be ignored.
|
||||||
revision, the attempt to set the period will fail.
|
|
||||||
<span class='since'>Since 1.1.1, requires QEMU 1.5</span>
|
<span class='since'>Since 1.1.1, requires QEMU 1.5</span>
|
||||||
</p>
|
</p>
|
||||||
</dd>
|
</dd>
|
||||||
|
@ -10492,6 +10492,7 @@ virDomainMemballoonDefParseXML(xmlNodePtr node,
|
|||||||
char *model;
|
char *model;
|
||||||
virDomainMemballoonDefPtr def;
|
virDomainMemballoonDefPtr def;
|
||||||
xmlNodePtr save = ctxt->node;
|
xmlNodePtr save = ctxt->node;
|
||||||
|
unsigned int period = 0;
|
||||||
|
|
||||||
if (VIR_ALLOC(def) < 0)
|
if (VIR_ALLOC(def) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -10510,12 +10511,16 @@ virDomainMemballoonDefParseXML(xmlNodePtr node,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctxt->node = node;
|
ctxt->node = node;
|
||||||
if (virXPathUInt("string(./stats/@period)", ctxt, &def->period) < -1) {
|
if (virXPathUInt("string(./stats/@period)", ctxt, &period) < -1) {
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
_("invalid statistics collection period"));
|
_("invalid statistics collection period"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def->period = period;
|
||||||
|
if (def->period < 0)
|
||||||
|
def->period = 0;
|
||||||
|
|
||||||
if (def->model == VIR_DOMAIN_MEMBALLOON_MODEL_NONE)
|
if (def->model == VIR_DOMAIN_MEMBALLOON_MODEL_NONE)
|
||||||
VIR_DEBUG("Ignoring device address for none model Memballoon");
|
VIR_DEBUG("Ignoring device address for none model Memballoon");
|
||||||
else if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0)
|
else if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0)
|
||||||
@ -18839,7 +18844,7 @@ virDomainMemballoonDefFormat(virBufferPtr buf,
|
|||||||
virBufferAdjustIndent(&childrenBuf, indent + 2);
|
virBufferAdjustIndent(&childrenBuf, indent + 2);
|
||||||
|
|
||||||
if (def->period)
|
if (def->period)
|
||||||
virBufferAsprintf(&childrenBuf, "<stats period='%u'/>\n", def->period);
|
virBufferAsprintf(&childrenBuf, "<stats period='%i'/>\n", def->period);
|
||||||
|
|
||||||
if (virDomainDeviceInfoNeedsFormat(&def->info, flags) &&
|
if (virDomainDeviceInfoNeedsFormat(&def->info, flags) &&
|
||||||
virDomainDeviceInfoFormat(&childrenBuf, &def->info, flags) < 0) {
|
virDomainDeviceInfoFormat(&childrenBuf, &def->info, flags) < 0) {
|
||||||
|
@ -1560,7 +1560,7 @@ enum {
|
|||||||
struct _virDomainMemballoonDef {
|
struct _virDomainMemballoonDef {
|
||||||
int model;
|
int model;
|
||||||
virDomainDeviceInfo info;
|
virDomainDeviceInfo info;
|
||||||
unsigned int period; /* seconds between collections */
|
int period; /* seconds between collections */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _virDomainNVRAMDef {
|
struct _virDomainNVRAMDef {
|
||||||
|
@ -4309,7 +4309,7 @@ int qemuProcessStart(virConnectPtr conn,
|
|||||||
virCommandPtr cmd = NULL;
|
virCommandPtr cmd = NULL;
|
||||||
struct qemuProcessHookData hookData;
|
struct qemuProcessHookData hookData;
|
||||||
unsigned long cur_balloon;
|
unsigned long cur_balloon;
|
||||||
unsigned int period = 0;
|
int period = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
bool rawio_set = false;
|
bool rawio_set = false;
|
||||||
char *nodeset = NULL;
|
char *nodeset = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user