[libvirt] [PATCH 0/2] Forbid negative blkio device values

Commits 0728d472 and 399394ab added suuport for VIR_DOMAIN_BLKIO_DEVICE_*, but all the values were parsed with underflow being allowed. Since there is no point in that, it should be fixed. Unfortunately the code is duplicated (apart from passing device/value pairs as a string :-/), so it needs to be fixed twice. This "series" fixes https://bugzilla.redhat.com/show_bug.cgi?id=1131306 Martin Kletzander (2): lxc: forbid negative blkio values qemu: forbid negative blkio values src/lxc/lxc_driver.c | 8 ++++---- src/qemu/qemu_driver.c | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) -- 2.0.4

Partially resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1131306 Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/lxc/lxc_driver.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 4741632..165e642 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -2185,16 +2185,16 @@ lxcDomainParseBlkioDeviceStr(char *blkioDeviceStr, const char *type, if (virStrToLong_ui(temp, &p, 10, &result[i].weight) < 0) goto error; } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS)) { - if (virStrToLong_ui(temp, &p, 10, &result[i].riops) < 0) + if (virStrToLong_uip(temp, &p, 10, &result[i].riops) < 0) goto error; } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS)) { - if (virStrToLong_ui(temp, &p, 10, &result[i].wiops) < 0) + if (virStrToLong_uip(temp, &p, 10, &result[i].wiops) < 0) goto error; } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_BPS)) { - if (virStrToLong_ull(temp, &p, 10, &result[i].rbps) < 0) + if (virStrToLong_ullp(temp, &p, 10, &result[i].rbps) < 0) goto error; } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS)){ - if (virStrToLong_ull(temp, &p, 10, &result[i].wbps) < 0) + if (virStrToLong_ullp(temp, &p, 10, &result[i].wbps) < 0) goto error; } else { goto error; -- 2.0.4

On Tue, Aug 19, 2014 at 03:10:54PM +0200, Martin Kletzander wrote:
Partially resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1131306
Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/lxc/lxc_driver.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 4741632..165e642 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -2185,16 +2185,16 @@ lxcDomainParseBlkioDeviceStr(char *blkioDeviceStr, const char *type, if (virStrToLong_ui(temp, &p, 10, &result[i].weight) < 0)
This "weight" parsing should use _uip too, of course, consider it changed as well (my local branch is fixed).
goto error; } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS)) { - if (virStrToLong_ui(temp, &p, 10, &result[i].riops) < 0) + if (virStrToLong_uip(temp, &p, 10, &result[i].riops) < 0) goto error; } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS)) { - if (virStrToLong_ui(temp, &p, 10, &result[i].wiops) < 0) + if (virStrToLong_uip(temp, &p, 10, &result[i].wiops) < 0) goto error; } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_BPS)) { - if (virStrToLong_ull(temp, &p, 10, &result[i].rbps) < 0) + if (virStrToLong_ullp(temp, &p, 10, &result[i].rbps) < 0) goto error; } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS)){ - if (virStrToLong_ull(temp, &p, 10, &result[i].wbps) < 0) + if (virStrToLong_ullp(temp, &p, 10, &result[i].wbps) < 0) goto error; } else { goto error; -- 2.0.4
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

Partially resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1131306 Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/qemu/qemu_driver.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d01920e..242eec4 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7652,19 +7652,19 @@ qemuDomainParseBlkioDeviceStr(char *blkioDeviceStr, const char *type, temp = p + 1; if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT)) { - if (virStrToLong_ui(temp, &p, 10, &result[i].weight) < 0) + if (virStrToLong_uip(temp, &p, 10, &result[i].weight) < 0) goto error; } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS)) { - if (virStrToLong_ui(temp, &p, 10, &result[i].riops) < 0) + if (virStrToLong_uip(temp, &p, 10, &result[i].riops) < 0) goto error; } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS)) { - if (virStrToLong_ui(temp, &p, 10, &result[i].wiops) < 0) + if (virStrToLong_uip(temp, &p, 10, &result[i].wiops) < 0) goto error; } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_BPS)) { - if (virStrToLong_ull(temp, &p, 10, &result[i].rbps) < 0) + if (virStrToLong_ullp(temp, &p, 10, &result[i].rbps) < 0) goto error; } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS)) { - if (virStrToLong_ull(temp, &p, 10, &result[i].wbps) < 0) + if (virStrToLong_ullp(temp, &p, 10, &result[i].wbps) < 0) goto error; } else { goto error; -- 2.0.4

On 08/19/2014 03:10 PM, Martin Kletzander wrote:
Commits 0728d472 and 399394ab added suuport for VIR_DOMAIN_BLKIO_DEVICE_*, but all the values were parsed with underflow being allowed. Since there is no point in that, it should be fixed. Unfortunately the code is duplicated (apart from passing device/value pairs as a string :-/), so it needs to be fixed twice.
Any suggestions for naming the file this could be split into are welcome: https://www.redhat.com/archives/libvir-list/2014-June/msg00789.html
This "series" fixes https://bugzilla.redhat.com/show_bug.cgi?id=1131306
Martin Kletzander (2): lxc: forbid negative blkio values qemu: forbid negative blkio values
src/lxc/lxc_driver.c | 8 ++++---- src/qemu/qemu_driver.c | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-)
ACK series Jan

On Wed, Aug 20, 2014 at 12:47:28PM +0200, Ján Tomko wrote:
On 08/19/2014 03:10 PM, Martin Kletzander wrote:
Commits 0728d472 and 399394ab added suuport for VIR_DOMAIN_BLKIO_DEVICE_*, but all the values were parsed with underflow being allowed. Since there is no point in that, it should be fixed. Unfortunately the code is duplicated (apart from passing device/value pairs as a string :-/), so it needs to be fixed twice.
Any suggestions for naming the file this could be split into are welcome: https://www.redhat.com/archives/libvir-list/2014-June/msg00789.html
Like, um..., domain_conf.c? Of any new file in _conf that'd be separated. How about putting all blkio- (and conf-) related stuff int blkio_conf.[hc]?
This "series" fixes https://bugzilla.redhat.com/show_bug.cgi?id=1131306
Martin Kletzander (2): lxc: forbid negative blkio values qemu: forbid negative blkio values
src/lxc/lxc_driver.c | 8 ++++---- src/qemu/qemu_driver.c | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-)
ACK series
Thanks, pushed now. Martin
participants (2)
-
Ján Tomko
-
Martin Kletzander