diff --git a/examples/xml/test/testdomfv0.xml b/examples/xml/test/testdomfv0.xml index fc209cce29..e60b5d69b7 100644 --- a/examples/xml/test/testdomfv0.xml +++ b/examples/xml/test/testdomfv0.xml @@ -38,4 +38,15 @@ + + 800 + + /dev/hda + 700 + 700 + 700 + 700 + 700 + + diff --git a/examples/xml/test/testnodeinline.xml b/examples/xml/test/testnodeinline.xml index 60970145a0..9165d9302d 100644 --- a/examples/xml/test/testnodeinline.xml +++ b/examples/xml/test/testnodeinline.xml @@ -48,6 +48,17 @@ + + 800 + + /dev/hda + 700 + 700 + 700 + 700 + 700 + + fc4 diff --git a/tests/virshtest.c b/tests/virshtest.c index 751e8ffc49..87da1f5889 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -30,6 +30,8 @@ main(void) tainted: custom device tree blob used\n\ tainted: use of deprecated configuration settings\n\ deprecated configuration: CPU model Deprecated-Test" +# define GET_BLKIO_PARAMETER "/dev/hda,700" +# define SET_BLKIO_PARAMETER "/dev/hda,1000" static const char *dominfo_fc4 = "\ Id: 2\n\ @@ -70,6 +72,25 @@ Security label: " SECURITY_LABEL "\n\ Messages: " FC5_MESSAGES "\n\ \n"; +static const char *get_blkio_parameters = "\ +weight : 800\n\ +device_weight : " GET_BLKIO_PARAMETER "\n\ +device_read_iops_sec: " GET_BLKIO_PARAMETER "\n\ +device_write_iops_sec: " GET_BLKIO_PARAMETER "\n\ +device_read_bytes_sec: " GET_BLKIO_PARAMETER "\n\ +device_write_bytes_sec: " GET_BLKIO_PARAMETER "\n\ +\n"; + +static const char *set_blkio_parameters = "\ +\n\ +weight : 500\n\ +device_weight : " SET_BLKIO_PARAMETER "\n\ +device_read_iops_sec: " SET_BLKIO_PARAMETER "\n\ +device_write_iops_sec: " SET_BLKIO_PARAMETER "\n\ +device_read_bytes_sec: " SET_BLKIO_PARAMETER "\n\ +device_write_bytes_sec: " SET_BLKIO_PARAMETER "\n\ +\n"; + static int testFilterLine(char *buffer, const char *toRemove) { @@ -291,6 +312,32 @@ static int testCompareDomControlInfoByName(const void *data G_GNUC_UNUSED) return testCompareOutputLit(exp, NULL, argv); } +static int testCompareGetBlkioParameters(const void *data G_GNUC_UNUSED) +{ + const char *const argv[] = { VIRSH_CUSTOM, "blkiotune", "fv0", NULL }; + const char *exp = get_blkio_parameters; + return testCompareOutputLit(exp, NULL, argv); +} + +static int testCompareSetBlkioParameters(const void *data G_GNUC_UNUSED) +{ + const char *const argv[] = { VIRSH_CUSTOM, "blkiotune fv0\ + --weight 500\ + --device-weights\ + " SET_BLKIO_PARAMETER "\ + --device-read-iops-sec\ + " SET_BLKIO_PARAMETER "\ + --device-write-iops-sec\ + " SET_BLKIO_PARAMETER "\ + --device-read-bytes-sec\ + " SET_BLKIO_PARAMETER "\ + --device-write-bytes-sec\ + " SET_BLKIO_PARAMETER ";\ + blkiotune fv0", NULL }; + const char *exp = set_blkio_parameters; + return testCompareOutputLit(exp, NULL, argv); +} + struct testInfo { const char *const *argv; const char *result; @@ -383,6 +430,14 @@ mymain(void) testCompareDomControlInfoByName, NULL) != 0) ret = -1; + if (virTestRun("virsh blkiotune (get parameters)", + testCompareGetBlkioParameters, NULL) != 0) + ret = -1; + + if (virTestRun("virsh blkiotune (set parameters)", + testCompareSetBlkioParameters, NULL) != 0) + ret = -1; + /* It's a bit awkward listing result before argument, but that's a * limitation of C99 vararg macros. */ # define DO_TEST(i, result, ...) \