[libvirt] [PATCH] libvirt-guests: Disable shutdown timeout
by Guido Günther
Since we can't know at service start how many VMs will be running we
can't calculate an apropriate shutdown timeout. So instead of killing
off the service just let it use it's own internal timeout mechanism.
References:
http://bugs.debian.org/803714
https://bugzilla.redhat.com/show_bug.cgi?id=1195544
---
tools/libvirt-guests.service.in | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/libvirt-guests.service.in b/tools/libvirt-guests.service.in
index cc04b6d..c31f663 100644
--- a/tools/libvirt-guests.service.in
+++ b/tools/libvirt-guests.service.in
@@ -13,6 +13,7 @@ ExecStop=@libexecdir(a)/libvirt-guests.sh stop
Type=oneshot
RemainAfterExit=yes
StandardOutput=journal+console
+TimeoutStopSec=0
[Install]
WantedBy=multi-user.target
--
2.6.2
9 years
[libvirt] [PATCH v2] tpm: adapt sysfs cancel path for new TPM driver
by Stefan Berger
This patch addresses BZ 1244895.
Adapt the sysfs TPM command cancel path for the TPM driver that
does not use a miscdevice anymore since Linux 4.0. Support old
and new paths and check their availability.
Add a mockup for the test cases to avoid the testing for
availability of the cancel path.
Signed-off-by: Stefan Berger <stefanb(a)linux.vnet.ibm.com>
---
src/util/virtpm.c | 21 ++++++++++++++++++---
tests/qemuxml2argvmock.c | 15 +++++++++++++++
2 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/src/util/virtpm.c b/src/util/virtpm.c
index 88f8361..6d9b065 100644
--- a/src/util/virtpm.c
+++ b/src/util/virtpm.c
@@ -26,6 +26,8 @@
#include "virstring.h"
#include "virerror.h"
+#include "viralloc.h"
+#include "virfile.h"
#include "virtpm.h"
#define VIR_FROM_THIS VIR_FROM_NONE
@@ -41,14 +43,27 @@ virTPMCreateCancelPath(const char *devpath)
{
char *path = NULL;
const char *dev;
+ const char *prefix[] = {"misc/", "tpm/"};
+ size_t i;
if (devpath) {
dev = strrchr(devpath, '/');
if (dev) {
dev++;
- if (virAsprintf(&path, "/sys/class/misc/%s/device/cancel",
- dev) < 0)
- goto cleanup;
+ for (i = 0; i < ARRAY_CARDINALITY(prefix); i++) {
+ if (virAsprintf(&path, "/sys/class/%s%s/device/cancel",
+ prefix[i], dev) < 0)
+ goto cleanup;
+
+ if (virFileExists(path))
+ break;
+
+ VIR_FREE(path);
+ }
+ if (!path)
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("No usable sysfs TPM cancel file could be "
+ "found"));
} else {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("TPM device path %s is invalid"), devpath);
diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c
index d24725e..e58b8ce 100644
--- a/tests/qemuxml2argvmock.c
+++ b/tests/qemuxml2argvmock.c
@@ -24,9 +24,13 @@
#include "virnuma.h"
#include "virmock.h"
#include "virutil.h"
+#include "virstring.h"
+#include "virtpm.h"
#include <time.h>
#include <unistd.h>
+#define VIR_FROM_THIS VIR_FROM_NONE
+
long virGetSystemPageSize(void)
{
return 4096;
@@ -59,3 +63,14 @@ virNumaNodeIsAvailable(int node)
return node >= 0 && node <= virNumaGetMaxNode();
}
#endif /* WITH_NUMACTL && HAVE_NUMA_BITMASK_ISBITSET */
+
+char *
+virTPMCreateCancelPath(const char *devpath)
+{
+ char *path;
+ (void)devpath;
+
+ ignore_value(VIR_STRDUP(path, "/sys/class/misc/tpm0/device/cancel"));
+
+ return path;
+}
--
2.4.3
9 years
[libvirt] storage sheepdog: allow to specify redundancy level
by Vasiliy Tolstov
Some storage backends allows to specify per volume redundancy options.
Sheepdog use x format for specify copies, and x:y format to specify
data and parity block count.
Signed-off-by: Alexey Tyabin <aleksey.tyabin(a)gmail.com>
Signed-off-by: Vasiliy Tolstov <v.tolstov(a)selfip.ru>
---
docs/schemas/storagevol.rng | 3 ++
src/conf/storage_conf.c | 2 +
src/storage/storage_backend_sheepdog.c | 45 +++++++++++---------
src/util/virstoragefile.c | 4 +-
src/util/virstoragefile.h | 2 +
tests/storagebackendsheepdogtest.c | 68 +++++++++++++++---------------
tests/storagevolxml2xmlin/vol-sheepdog.xml | 1 +
7 files changed, 71 insertions(+), 54 deletions(-)
diff --git a/docs/schemas/storagevol.rng b/docs/schemas/storagevol.rng
index 7450547..068993f 100644
--- a/docs/schemas/storagevol.rng
+++ b/docs/schemas/storagevol.rng
@@ -55,6 +55,9 @@
<element name='allocation'>
<ref name='scaledInteger'/>
</element>
+ <element name='redundancy'>
+ <ref name='string'/>
+ </element>
</optional>
</interleave>
</define>
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 9b8abea..d37c93a 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -1345,6 +1345,8 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
ret->target.allocation = ret->target.capacity;
}
+ ret->target.redundancy = virXPathString("string(./redundancy)", ctxt);
+
ret->target.path = virXPathString("string(./target/path)", ctxt);
if (options->formatFromString) {
char *format = virXPathString("string(./target/format/@type)", ctxt);
diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_backend_sheepdog.c
index 1200813..d070dfb 100644
--- a/src/storage/storage_backend_sheepdog.c
+++ b/src/storage/storage_backend_sheepdog.c
@@ -275,6 +275,10 @@ virStorageBackendSheepdogBuildVol(virConnectPtr conn ATTRIBUTE_UNUSED,
cmd = virCommandNewArgList(SHEEPDOGCLI, "vdi", "create", vol->name, NULL);
virCommandAddArgFormat(cmd, "%llu", vol->target.capacity);
+
+ if(NULL != vol->target.redundancy)
+ virCommandAddArgFormat(cmd, "-c %s", vol->target.redundancy);
+
virStorageBackendSheepdogAddHostArg(cmd, pool);
if (virCommandRun(cmd, NULL) < 0)
goto cleanup;
@@ -291,22 +295,23 @@ virStorageBackendSheepdogParseVdiList(virStorageVolDefPtr vol,
char *output)
{
/* fields:
- * current/clone/snapshot, name, id, size, used, shared, creation time, vdi id, [tag]
+ * current/clone/snapshot, name, id, size, used, shared, creation time, vdi id, redundancy, [tag], size shift
*
* example output:
- * s test 1 10 0 0 1336556634 7c2b25
- * s test 2 10 0 0 1336557203 7c2b26
- * = test 3 10 0 0 1336557216 7c2b27
+ * s test 1 10 0 0 1336556634 7c2b25 1 tt 22
+ * s test 2 10 0 0 1336557203 7c2b26 2 zz 22
+ * = test 3 10 0 0 1336557216 7c2b27 3 xx 22
*/
- int id;
+ char **args;
const char *p, *next;
-
+ int ret = -1;
+ size_t tokcount = 0;
vol->target.allocation = vol->target.capacity = 0;
+ vol->target.redundancy = NULL;
p = output;
do {
- char *end;
if ((next = strchr(p, '\n')))
++next;
@@ -327,24 +332,24 @@ virStorageBackendSheepdogParseVdiList(virStorageVolDefPtr vol,
++p;
++p;
}
+ break;
+ } while ((p = next));
- if (virStrToLong_i(p, &end, 10, &id) < 0)
- return -1;
-
- p = end + 1;
-
- if (virStrToLong_ull(p, &end, 10, &vol->target.capacity) < 0)
- return -1;
+ if ((args = virStringSplitCount(p, " ", 9, &tokcount)) == NULL || tokcount < 5)
+ goto cleanup;
- p = end + 1;
+ if ((ret = virStrToLong_ull(args[1], NULL, 10, &vol->target.capacity)) < 0)
+ goto cleanup;
- if (virStrToLong_ull(p, &end, 10, &vol->target.allocation) < 0)
- return -1;
+ if ((ret = virStrToLong_ull(args[2], NULL, 10, &vol->target.allocation)) < 0)
+ goto cleanup;
- return 0;
- } while ((p = next));
+ if ((ret = VIR_STRDUP(vol->target.redundancy, args[5])) < 0)
+ goto cleanup;
- return -1;
+ cleanup:
+ virStringFreeList(args);
+ return ret;
}
static int
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 2aa1d90..9cdc90d 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -1846,7 +1846,8 @@ virStorageSourceCopy(const virStorageSource *src,
VIR_STRDUP(ret->backingStoreRaw, src->backingStoreRaw) < 0 ||
VIR_STRDUP(ret->snapshot, src->snapshot) < 0 ||
VIR_STRDUP(ret->configFile, src->configFile) < 0 ||
- VIR_STRDUP(ret->compat, src->compat) < 0)
+ VIR_STRDUP(ret->compat, src->compat) < 0 ||
+ VIR_STRDUP(ret->redundancy, src->redundancy) < 0)
goto error;
if (src->nhosts) {
@@ -2040,6 +2041,7 @@ virStorageSourceClear(virStorageSourcePtr def)
VIR_FREE(def->volume);
VIR_FREE(def->snapshot);
VIR_FREE(def->configFile);
+ VIR_FREE(def->redundancy);
virStorageSourcePoolDefFree(def->srcpool);
VIR_FREE(def->driverName);
virBitmapFree(def->features);
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index b98fe25..c37cfc2 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -282,6 +282,8 @@ struct _virStorageSource {
/* Name of the child backing store recorded in metadata of the
* current file. */
char *backingStoreRaw;
+ /* redundancy level, may be used by sheepdog or ceph */
+ char *redundancy;
};
diff --git a/tests/storagebackendsheepdogtest.c b/tests/storagebackendsheepdogtest.c
index 2b0f4db..c037ebe 100644
--- a/tests/storagebackendsheepdogtest.c
+++ b/tests/storagebackendsheepdogtest.c
@@ -42,6 +42,7 @@ typedef struct {
int expected_return;
uint64_t expected_capacity;
uint64_t expected_allocation;
+ const char *expected_redundancy;
} collie_test;
struct testNodeInfoParserData {
@@ -119,7 +120,8 @@ test_vdi_list_parser(const void *opaque)
}
if (vol->target.capacity == test.expected_capacity &&
- vol->target.allocation == test.expected_allocation)
+ vol->target.allocation == test.expected_allocation &&
+ !strcmp(vol->target.redundancy, test.expected_redundancy))
ret = 0;
cleanup:
@@ -138,41 +140,41 @@ mymain(void)
char *volxml = NULL;
collie_test node_info_tests[] = {
- {"", -1, 0, 0},
- {"Total 15245667872 117571104 0% 20972341\n", 0, 15245667872, 117571104},
- {"To", -1, 0, 0},
- {"asdf\nasdf", -1, 0, 0},
- {"Total ", -1, 0, 0},
- {"Total 1", -1, 0, 0},
- {"Total 1\n", -1, 0, 0},
- {"Total 1 ", -1, 0, 0},
- {"Total 1 2", -1, 0, 0},
- {"Total 1 2 ", -1, 0, 0},
- {"Total 1 2\n", 0, 1, 2},
- {"Total 1 2 \n", 0, 1, 2},
- {"Total a 2 \n", -1, 0, 0},
- {"Total 1 b \n", -1, 0, 0},
- {"Total a b \n", -1, 0, 0},
- {"stuff\nTotal 1 2 \n", 0, 1, 2},
- {"0 1 2 3\nTotal 1 2 \n", 0, 1, 2},
- {NULL, 0, 0, 0}
+ {"", -1, 0, 0,"0"},
+ {"Total 15245667872 117571104 1 0% 20972341\n", 0, 15245667872, 117571104,"1"},
+ {"To", -1, 0, 0," "},
+ {"asdf\nasdf", -1, 0, 0," "},
+ {"Total ", -1, 0, 0, " "},
+ {"Total 1", -1, 0, 0, " "},
+ {"Total 1\n", -1, 0, 0," "},
+ {"Total 1 ", -1, 0, 0, " "},
+ {"Total 1 2", -1, 0, 0, " "},
+ {"Total 1 2 ", -1, 0, 0," "},
+ {"Total 1 2 1:1\n", 0, 1, 2,"1:1"},
+ {"Total 1 2 3:4\n", 0, 1, 2,"3:4"},
+ {"Total a 2 \n", -1, 0, 0," "},
+ {"Total 1 b \n", -1, 0, 0," "},
+ {"Total a b \n", -1, 0, 0,"sss"},
+ {"stuff\nTotal 1 2 1:2\n", 0, 1, 2,"1:2"},
+ {"0 1 2 3\nTotal 1 2 3\n", 0, 1, 2,"3"},
+ {NULL, 0, 0, 0, NULL}
};
collie_test vdi_list_tests[] = {
- {"", -1, 0, 0},
- {"= test 3 10 20 0 1336557216 7c2b27\n", 0, 10, 20},
- {"= test\\ with\\ spaces 3 10 20 0 1336557216 7c2b27\n", 0, 10, 20},
- {"= backslashattheend\\\\ 3 10 20 0 1336557216 7c2b27\n", 0, 10, 20},
- {"s test 1 10 20 0 1336556634 7c2b25\n= test 3 50 60 0 1336557216 7c2b27\n", 0, 50, 60},
- {"=", -1, 0, 0},
- {"= test", -1, 0, 0},
- {"= test ", -1, 0, 0},
- {"= test 1", -1, 0, 0},
- {"= test 1 ", -1, 0, 0},
- {"= test 1 2", -1, 0, 0},
- {"= test 1 2 ", -1, 0, 0},
- {"= test 1 2 3", -1, 0, 0},
- {NULL, 0, 0, 0}
+ {"", -1, 0, 0,NULL},
+ {"= test 3 10 20 1 0 1336557216 7c2b27 1\n", 0, 10, 20, "1"},
+ {"= test\\ with\\ spaces 3 10 20 0 1336557216 7c2b27 3:4\n", 0, 10, 20, "3:4"},
+ {"= backslashattheend\\\\ 3 10 20 0 1336557216 7c2b27 1\n", 0, 10, 20, "1"},
+ {"s test 1 10 20 0 1336556634 7c2b25 2\n= test 3 50 60 0 1336557216 7c2b27 2:3\n", 0, 50, 60, "2:3"},
+ {"=", -1, 0, 0," "},
+ {"= test", -1, 0, 0," "},
+ {"= test ", -1, 0, 0," "},
+ {"= test 1", -1, 0, 0," "},
+ {"= test 1 ", -1, 0, 0," "},
+ {"= test 1 2", -1, 0, 0," "},
+ {"= test 1 2 ", -1, 0, 0," "},
+ {"= test 1 2 3", -1, 0, 0," "},
+ {NULL, 0, 0, 0,NULL}
};
collie_test *test = node_info_tests;
diff --git a/tests/storagevolxml2xmlin/vol-sheepdog.xml b/tests/storagevolxml2xmlin/vol-sheepdog.xml
index d6e920b..f88e6db 100644
--- a/tests/storagevolxml2xmlin/vol-sheepdog.xml
+++ b/tests/storagevolxml2xmlin/vol-sheepdog.xml
@@ -4,6 +4,7 @@
</source>
<capacity unit='bytes'>1024</capacity>
<allocation unit='bytes'>0</allocation>
+ <redundancy unit='string'>3</redundancy>
<target>
<path>sheepdog:test2</path>
</target>
--
2.5.0
9 years
[libvirt] [PATCH v2] tpm: adapt sysfs cancel path for new TPM driver
by Stefan Berger
Adapt the sysfs TPM command cancel path for the TPM driver that
does not use a miscdevice anymore since Linux 4.0. Support old
and new paths and check their availability.
Add a mockup for the test cases to avoid the testing for
availability of the cancel path.
Signed-off-by: Stefan Berger <stefanb(a)linux.vnet.ibm.com>
---
src/util/virtpm.c | 22 ++++++++++++++++++++--
tests/qemuxml2argvmock.c | 15 +++++++++++++++
2 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/src/util/virtpm.c b/src/util/virtpm.c
index 88f8361..3872a31 100644
--- a/src/util/virtpm.c
+++ b/src/util/virtpm.c
@@ -23,9 +23,12 @@
#include <config.h>
#include <sys/stat.h>
+#include <fcntl.h>
#include "virstring.h"
#include "virerror.h"
+#include "viralloc.h"
+#include "virfile.h"
#include "virtpm.h"
#define VIR_FROM_THIS VIR_FROM_NONE
@@ -41,13 +44,28 @@ virTPMCreateCancelPath(const char *devpath)
{
char *path = NULL;
const char *dev;
+ const char *prefix[] = {"misc/", "tpm/"};
+ size_t i;
+ int fd;
if (devpath) {
dev = strrchr(devpath, '/');
if (dev) {
dev++;
- if (virAsprintf(&path, "/sys/class/misc/%s/device/cancel",
- dev) < 0)
+ for (i = 0; i < ARRAY_CARDINALITY(prefix); i++) {
+ if (virAsprintf(&path, "/sys/class/%s%s/device/cancel",
+ prefix[i], dev) < 0)
+ goto cleanup;
+
+ fd = open(path, O_WRONLY);
+ if (fd >= 0) {
+ VIR_FORCE_CLOSE(fd);
+ break;
+ }
+ VIR_FREE(path);
+ }
+ /* /dev/null does not allow to cancel cmds but it can be used */
+ if (!path && virAsprintf(&path, "/dev/null") < 0)
goto cleanup;
} else {
virReportError(VIR_ERR_INTERNAL_ERROR,
diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c
index d24725e..e58b8ce 100644
--- a/tests/qemuxml2argvmock.c
+++ b/tests/qemuxml2argvmock.c
@@ -24,9 +24,13 @@
#include "virnuma.h"
#include "virmock.h"
#include "virutil.h"
+#include "virstring.h"
+#include "virtpm.h"
#include <time.h>
#include <unistd.h>
+#define VIR_FROM_THIS VIR_FROM_NONE
+
long virGetSystemPageSize(void)
{
return 4096;
@@ -59,3 +63,14 @@ virNumaNodeIsAvailable(int node)
return node >= 0 && node <= virNumaGetMaxNode();
}
#endif /* WITH_NUMACTL && HAVE_NUMA_BITMASK_ISBITSET */
+
+char *
+virTPMCreateCancelPath(const char *devpath)
+{
+ char *path;
+ (void)devpath;
+
+ ignore_value(VIR_STRDUP(path, "/sys/class/misc/tpm0/device/cancel"));
+
+ return path;
+}
--
2.4.3
9 years
Re: [libvirt] [PATCH v2] tpm: adapt sysfs cancel path for new TPM driver
by Cole Robinson
On 11/17/2015 04:26 PM, Stefan Berger wrote:
> Cole Robinson <crobinso(a)redhat.com> wrote on 11/17/2015 03:55:13 PM:
>
>> From: Cole Robinson <crobinso(a)redhat.com>
>> To: Stefan Berger <stefanb(a)linux.vnet.ibm.com>, Stefan Berger/
>> Watson/IBM@IBMUS, libvir-list(a)redhat.com, berrange(a)redhat.com
>> Date: 11/17/2015 03:55 PM
>> Subject: Re: [PATCH v2] tpm: adapt sysfs cancel path for new TPM driver
>>
>> On 11/17/2015 03:49 PM, Stefan Berger wrote:
>> > On 11/17/2015 02:12 PM, Cole Robinson wrote:
>> >> First, thanks for following up on the fedora bugs so quickly!
>> >>
>> >> On 11/17/2015 10:46 AM, Stefan Berger wrote:
>> >>> Adapt the sysfs TPM command cancel path for the TPM driver that
>> >>> does not use a miscdevice anymore since Linux 4.0. Support old
>> >>> and new paths and check their availability.
>> >>>
>> >>> Add a mockup for the test cases to avoid the testing for
>> >>> availability of the cancel path.
>> >>>
>> >> I see you sent a qemu patch for a similar change. What's the benefit of
>> >> libvirt setting cancel_path if qemu can (and already attempts to)figure it
>> >> out?
>> >
>> > The only benefit is that libvirt is controlling the parameter.
>> >
>>
>> Then IMO we should let qemu handle it and just drop this path handling
>> entirely. If there's ever a need to differentiate from qemu's logic or let the
>> user override this value then we can add it back without much trouble
>>
>
> Forgot about that: SELinux labeling of that file requires it afaik.
>
Ah gotchya. Makes sense
- Cole
9 years
[libvirt] [PATCH 1/1] virt-aa-helper: support OVMF
by Serge Hallyn
As suggested by Jamie Strandboge in
https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1483071
Signed-off-by: Serge Hallyn <serge.hallyn(a)ubuntu.com>
---
src/security/virt-aa-helper.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index 5de56e5..bddcbdc 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -575,7 +575,8 @@ valid_path(const char *path, const bool readonly)
/* override the above with these */
const char * const override[] = {
"/sys/devices/pci", /* for hostdev pci devices */
- "/etc/libvirt-sandbox/services/" /* for virt-sandbox service config */
+ "/etc/libvirt-sandbox/services/", /* for virt-sandbox service config */
+ "/usr/share/ovmf/" /* for OVMF images */
};
const int nropaths = ARRAY_CARDINALITY(restricted);
--
2.5.0
9 years
[libvirt] [PATCH] tpm: adapt sysfs cancel path for new TPM driver
by Stefan Berger
Adapt the sysfs TPM command cancel path for the TPM driver that
does not use a miscdevice anymore since Linux 4.0. Support old
and new paths.
Signed-off-by: Stefan Berger <stefanb(a)linux.vnet.ibm.com>
---
src/util/virtpm.c | 21 +++++++++++++++++++--
.../qemuxml2argv-tpm-passthrough.args | 2 +-
2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/src/util/virtpm.c b/src/util/virtpm.c
index 88f8361..40a758b 100644
--- a/src/util/virtpm.c
+++ b/src/util/virtpm.c
@@ -23,9 +23,12 @@
#include <config.h>
#include <sys/stat.h>
+#include <fcntl.h>
#include "virstring.h"
#include "virerror.h"
+#include "viralloc.h"
+#include "virfile.h"
#include "virtpm.h"
#define VIR_FROM_THIS VIR_FROM_NONE
@@ -41,13 +44,27 @@ virTPMCreateCancelPath(const char *devpath)
{
char *path = NULL;
const char *dev;
+ const char *prefix[] = {"misc/", "tpm/"};
+ int i, fd;
if (devpath) {
dev = strrchr(devpath, '/');
if (dev) {
dev++;
- if (virAsprintf(&path, "/sys/class/misc/%s/device/cancel",
- dev) < 0)
+ for (i = 0; i < ARRAY_CARDINALITY(prefix); i++) {
+ if (virAsprintf(&path, "/sys/class/%s%s/device/cancel",
+ prefix[i], dev) < 0)
+ goto cleanup;
+
+ fd = open(path, O_WRONLY);
+ if (fd >= 0) {
+ VIR_FORCE_CLOSE(fd);
+ break;
+ }
+ VIR_FREE(path);
+ }
+ /* /dev/null does not allow to cancel cmds but it can be used */
+ if (!path && virAsprintf(&path, "/dev/null") < 0)
goto cleanup;
} else {
virReportError(VIR_ERR_INTERNAL_ERROR,
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-tpm-passthrough.args b/tests/qemuxml2argvdata/qemuxml2argv-tpm-passthrough.args
index f33120f..1e48603 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-tpm-passthrough.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-tpm-passthrough.args
@@ -17,6 +17,6 @@ QEMU_AUDIO_DRV=none \
-boot c \
-usb \
-tpmdev passthrough,id=tpm-tpm0,path=/dev/tpm0,\
-cancel-path=/sys/class/misc/tpm0/device/cancel \
+cancel-path=/dev/null \
-device tpm-tis,tpmdev=tpm-tpm0,id=tpm0 \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
--
2.4.3
9 years
[libvirt] [QEMU PATCH] target-i386: Disable rdtscp on Opteron_G* CPU models
by Eduardo Habkost
KVM can't virtualize rdtscp on AMD CPUs yet, so there's no point
in enabling it by default on AMD CPU models, as all we are
getting are confused users because of the "host doesn't support
requested feature" warnings.
Disable rdtscp on Opteron_G* models, but keep compatibility on
pc-*-2.4 and older (just in case there are people are doing funny
stuff using AMD CPU models on Intel hosts).
Signed-off-by: Eduardo Habkost <ehabkost(a)redhat.com>
---
include/hw/i386/pc.h | 17 +++++++++++++++++
target-i386/cpu.c | 12 ++++++++----
2 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 4bbc0ff..854c330 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -347,8 +347,25 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
.driver = "qemu32" "-" TYPE_X86_CPU,\
.property = "popcnt",\
.value = "on",\
+ },{\
+ .driver = "Opteron_G2" "-" TYPE_X86_CPU,\
+ .property = "rdtscp",\
+ .value = "on",\
+ },{\
+ .driver = "Opteron_G3" "-" TYPE_X86_CPU,\
+ .property = "rdtscp",\
+ .value = "on",\
+ },{\
+ .driver = "Opteron_G4" "-" TYPE_X86_CPU,\
+ .property = "rdtscp",\
+ .value = "on",\
+ },{\
+ .driver = "Opteron_G5" "-" TYPE_X86_CPU,\
+ .property = "rdtscp",\
+ .value = "on",\
},
+
#define PC_COMPAT_2_3 \
PC_COMPAT_2_4 \
HW_COMPAT_2_3 \
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index e5f1c5b..11e5e39 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1244,8 +1244,9 @@ static X86CPUDefinition builtin_x86_defs[] = {
CPUID_DE | CPUID_FP87,
.features[FEAT_1_ECX] =
CPUID_EXT_CX16 | CPUID_EXT_SSE3,
+ /* Missing: CPUID_EXT2_RDTSCP */
.features[FEAT_8000_0001_EDX] =
- CPUID_EXT2_LM | CPUID_EXT2_RDTSCP | CPUID_EXT2_FXSR |
+ CPUID_EXT2_LM | CPUID_EXT2_FXSR |
CPUID_EXT2_MMX | CPUID_EXT2_NX | CPUID_EXT2_PSE36 |
CPUID_EXT2_PAT | CPUID_EXT2_CMOV | CPUID_EXT2_MCA |
CPUID_EXT2_PGE | CPUID_EXT2_MTRR | CPUID_EXT2_SYSCALL |
@@ -1273,8 +1274,9 @@ static X86CPUDefinition builtin_x86_defs[] = {
.features[FEAT_1_ECX] =
CPUID_EXT_POPCNT | CPUID_EXT_CX16 | CPUID_EXT_MONITOR |
CPUID_EXT_SSE3,
+ /* Missing: CPUID_EXT2_RDTSCP */
.features[FEAT_8000_0001_EDX] =
- CPUID_EXT2_LM | CPUID_EXT2_RDTSCP | CPUID_EXT2_FXSR |
+ CPUID_EXT2_LM | CPUID_EXT2_FXSR |
CPUID_EXT2_MMX | CPUID_EXT2_NX | CPUID_EXT2_PSE36 |
CPUID_EXT2_PAT | CPUID_EXT2_CMOV | CPUID_EXT2_MCA |
CPUID_EXT2_PGE | CPUID_EXT2_MTRR | CPUID_EXT2_SYSCALL |
@@ -1305,8 +1307,9 @@ static X86CPUDefinition builtin_x86_defs[] = {
CPUID_EXT_POPCNT | CPUID_EXT_SSE42 | CPUID_EXT_SSE41 |
CPUID_EXT_CX16 | CPUID_EXT_SSSE3 | CPUID_EXT_PCLMULQDQ |
CPUID_EXT_SSE3,
+ /* Missing: CPUID_EXT2_RDTSCP */
.features[FEAT_8000_0001_EDX] =
- CPUID_EXT2_LM | CPUID_EXT2_RDTSCP |
+ CPUID_EXT2_LM |
CPUID_EXT2_PDPE1GB | CPUID_EXT2_FXSR | CPUID_EXT2_MMX |
CPUID_EXT2_NX | CPUID_EXT2_PSE36 | CPUID_EXT2_PAT |
CPUID_EXT2_CMOV | CPUID_EXT2_MCA | CPUID_EXT2_PGE |
@@ -1340,8 +1343,9 @@ static X86CPUDefinition builtin_x86_defs[] = {
CPUID_EXT_AES | CPUID_EXT_POPCNT | CPUID_EXT_SSE42 |
CPUID_EXT_SSE41 | CPUID_EXT_CX16 | CPUID_EXT_FMA |
CPUID_EXT_SSSE3 | CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSE3,
+ /* Missing: CPUID_EXT2_RDTSCP */
.features[FEAT_8000_0001_EDX] =
- CPUID_EXT2_LM | CPUID_EXT2_RDTSCP |
+ CPUID_EXT2_LM |
CPUID_EXT2_PDPE1GB | CPUID_EXT2_FXSR | CPUID_EXT2_MMX |
CPUID_EXT2_NX | CPUID_EXT2_PSE36 | CPUID_EXT2_PAT |
CPUID_EXT2_CMOV | CPUID_EXT2_MCA | CPUID_EXT2_PGE |
--
2.1.0
9 years
[libvirt] storage sheepdog: allow to specify redundancy level
by Vasiliy Tolstov
Some storage backends allows to specify per volume redundancy options.
Sheepdog use x format for specify copies, and x:y format to specify
data and parity block count.
Signed-off-by: Alexey Tyabin <aleksey.tyabin(a)gmail.com>
Signed-off-by: Vasiliy Tolstov <v.tolstov(a)selfip.ru>
---
docs/schemas/storagevol.rng | 3 ++
src/conf/storage_conf.c | 2 +
src/storage/storage_backend_sheepdog.c | 38 +++++++++--------
src/util/virstoragefile.c | 4 +-
src/util/virstoragefile.h | 2 +
tests/storagebackendsheepdogtest.c | 68 +++++++++++++++---------------
tests/storagevolxml2xmlin/vol-sheepdog.xml | 1 +
7 files changed, 66 insertions(+), 52 deletions(-)
diff --git a/docs/schemas/storagevol.rng b/docs/schemas/storagevol.rng
index 7450547..068993f 100644
--- a/docs/schemas/storagevol.rng
+++ b/docs/schemas/storagevol.rng
@@ -55,6 +55,9 @@
<element name='allocation'>
<ref name='scaledInteger'/>
</element>
+ <element name='redundancy'>
+ <ref name='string'/>
+ </element>
</optional>
</interleave>
</define>
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 9b8abea..d37c93a 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -1345,6 +1345,8 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
ret->target.allocation = ret->target.capacity;
}
+ ret->target.redundancy = virXPathString("string(./redundancy)", ctxt);
+
ret->target.path = virXPathString("string(./target/path)", ctxt);
if (options->formatFromString) {
char *format = virXPathString("string(./target/format/@type)", ctxt);
diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_backend_sheepdog.c
index 1200813..565cfd0 100644
--- a/src/storage/storage_backend_sheepdog.c
+++ b/src/storage/storage_backend_sheepdog.c
@@ -275,6 +275,10 @@ virStorageBackendSheepdogBuildVol(virConnectPtr conn ATTRIBUTE_UNUSED,
cmd = virCommandNewArgList(SHEEPDOGCLI, "vdi", "create", vol->name, NULL);
virCommandAddArgFormat(cmd, "%llu", vol->target.capacity);
+
+ if(NULL != vol->target.redundancy)
+ virCommandAddArgFormat(cmd, "-c %s", vol->target.redundancy);
+
virStorageBackendSheepdogAddHostArg(cmd, pool);
if (virCommandRun(cmd, NULL) < 0)
goto cleanup;
@@ -291,18 +295,19 @@ virStorageBackendSheepdogParseVdiList(virStorageVolDefPtr vol,
char *output)
{
/* fields:
- * current/clone/snapshot, name, id, size, used, shared, creation time, vdi id, [tag]
+ * current/clone/snapshot, name, id, size, used, shared, creation time, vdi id, redundancy, [tag], size shift
*
* example output:
- * s test 1 10 0 0 1336556634 7c2b25
- * s test 2 10 0 0 1336557203 7c2b26
- * = test 3 10 0 0 1336557216 7c2b27
+ * s test 1 10 0 0 1336556634 7c2b25 1 tt 22
+ * s test 2 10 0 0 1336557203 7c2b26 2 zz 22
+ * = test 3 10 0 0 1336557216 7c2b27 3 xx 22
*/
- int id;
+ char **args;
const char *p, *next;
vol->target.allocation = vol->target.capacity = 0;
+ vol->target.redundancy = NULL;
p = output;
do {
@@ -327,24 +332,21 @@ virStorageBackendSheepdogParseVdiList(virStorageVolDefPtr vol,
++p;
++p;
}
+ }
+ args = virStringSplit(p, " ", 9);
- if (virStrToLong_i(p, &end, 10, &id) < 0)
- return -1;
-
- p = end + 1;
-
- if (virStrToLong_ull(p, &end, 10, &vol->target.capacity) < 0)
- return -1;
+ if (virStrToLong_ull(args[1], strlen(args[1]), 10, &vol->target.capacity) < 0)
+ return -1;
- p = end + 1;
+ if (virStrToLong_ull(args[2], strlen(args[2]), 10, &vol->target.allocation) < 0)
+ return -1;
- if (virStrToLong_ull(p, &end, 10, &vol->target.allocation) < 0)
- return -1;
+ if (VIR_STRNDUP(vol->target.redundancy, args[5], strlen(args[2])) < 0)
+ return -1;
- return 0;
- } while ((p = next));
+ virStringFreeList(args);
- return -1;
+ return 0;
}
static int
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 2aa1d90..9cdc90d 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -1846,7 +1846,8 @@ virStorageSourceCopy(const virStorageSource *src,
VIR_STRDUP(ret->backingStoreRaw, src->backingStoreRaw) < 0 ||
VIR_STRDUP(ret->snapshot, src->snapshot) < 0 ||
VIR_STRDUP(ret->configFile, src->configFile) < 0 ||
- VIR_STRDUP(ret->compat, src->compat) < 0)
+ VIR_STRDUP(ret->compat, src->compat) < 0 ||
+ VIR_STRDUP(ret->redundancy, src->redundancy) < 0)
goto error;
if (src->nhosts) {
@@ -2040,6 +2041,7 @@ virStorageSourceClear(virStorageSourcePtr def)
VIR_FREE(def->volume);
VIR_FREE(def->snapshot);
VIR_FREE(def->configFile);
+ VIR_FREE(def->redundancy);
virStorageSourcePoolDefFree(def->srcpool);
VIR_FREE(def->driverName);
virBitmapFree(def->features);
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index b98fe25..c37cfc2 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -282,6 +282,8 @@ struct _virStorageSource {
/* Name of the child backing store recorded in metadata of the
* current file. */
char *backingStoreRaw;
+ /* redundancy level, may be used by sheepdog or ceph */
+ char *redundancy;
};
diff --git a/tests/storagebackendsheepdogtest.c b/tests/storagebackendsheepdogtest.c
index 2b0f4db..c037ebe 100644
--- a/tests/storagebackendsheepdogtest.c
+++ b/tests/storagebackendsheepdogtest.c
@@ -42,6 +42,7 @@ typedef struct {
int expected_return;
uint64_t expected_capacity;
uint64_t expected_allocation;
+ const char *expected_redundancy;
} collie_test;
struct testNodeInfoParserData {
@@ -119,7 +120,8 @@ test_vdi_list_parser(const void *opaque)
}
if (vol->target.capacity == test.expected_capacity &&
- vol->target.allocation == test.expected_allocation)
+ vol->target.allocation == test.expected_allocation &&
+ !strcmp(vol->target.redundancy, test.expected_redundancy))
ret = 0;
cleanup:
@@ -138,41 +140,41 @@ mymain(void)
char *volxml = NULL;
collie_test node_info_tests[] = {
- {"", -1, 0, 0},
- {"Total 15245667872 117571104 0% 20972341\n", 0, 15245667872, 117571104},
- {"To", -1, 0, 0},
- {"asdf\nasdf", -1, 0, 0},
- {"Total ", -1, 0, 0},
- {"Total 1", -1, 0, 0},
- {"Total 1\n", -1, 0, 0},
- {"Total 1 ", -1, 0, 0},
- {"Total 1 2", -1, 0, 0},
- {"Total 1 2 ", -1, 0, 0},
- {"Total 1 2\n", 0, 1, 2},
- {"Total 1 2 \n", 0, 1, 2},
- {"Total a 2 \n", -1, 0, 0},
- {"Total 1 b \n", -1, 0, 0},
- {"Total a b \n", -1, 0, 0},
- {"stuff\nTotal 1 2 \n", 0, 1, 2},
- {"0 1 2 3\nTotal 1 2 \n", 0, 1, 2},
- {NULL, 0, 0, 0}
+ {"", -1, 0, 0,"0"},
+ {"Total 15245667872 117571104 1 0% 20972341\n", 0, 15245667872, 117571104,"1"},
+ {"To", -1, 0, 0," "},
+ {"asdf\nasdf", -1, 0, 0," "},
+ {"Total ", -1, 0, 0, " "},
+ {"Total 1", -1, 0, 0, " "},
+ {"Total 1\n", -1, 0, 0," "},
+ {"Total 1 ", -1, 0, 0, " "},
+ {"Total 1 2", -1, 0, 0, " "},
+ {"Total 1 2 ", -1, 0, 0," "},
+ {"Total 1 2 1:1\n", 0, 1, 2,"1:1"},
+ {"Total 1 2 3:4\n", 0, 1, 2,"3:4"},
+ {"Total a 2 \n", -1, 0, 0," "},
+ {"Total 1 b \n", -1, 0, 0," "},
+ {"Total a b \n", -1, 0, 0,"sss"},
+ {"stuff\nTotal 1 2 1:2\n", 0, 1, 2,"1:2"},
+ {"0 1 2 3\nTotal 1 2 3\n", 0, 1, 2,"3"},
+ {NULL, 0, 0, 0, NULL}
};
collie_test vdi_list_tests[] = {
- {"", -1, 0, 0},
- {"= test 3 10 20 0 1336557216 7c2b27\n", 0, 10, 20},
- {"= test\\ with\\ spaces 3 10 20 0 1336557216 7c2b27\n", 0, 10, 20},
- {"= backslashattheend\\\\ 3 10 20 0 1336557216 7c2b27\n", 0, 10, 20},
- {"s test 1 10 20 0 1336556634 7c2b25\n= test 3 50 60 0 1336557216 7c2b27\n", 0, 50, 60},
- {"=", -1, 0, 0},
- {"= test", -1, 0, 0},
- {"= test ", -1, 0, 0},
- {"= test 1", -1, 0, 0},
- {"= test 1 ", -1, 0, 0},
- {"= test 1 2", -1, 0, 0},
- {"= test 1 2 ", -1, 0, 0},
- {"= test 1 2 3", -1, 0, 0},
- {NULL, 0, 0, 0}
+ {"", -1, 0, 0,NULL},
+ {"= test 3 10 20 1 0 1336557216 7c2b27 1\n", 0, 10, 20, "1"},
+ {"= test\\ with\\ spaces 3 10 20 0 1336557216 7c2b27 3:4\n", 0, 10, 20, "3:4"},
+ {"= backslashattheend\\\\ 3 10 20 0 1336557216 7c2b27 1\n", 0, 10, 20, "1"},
+ {"s test 1 10 20 0 1336556634 7c2b25 2\n= test 3 50 60 0 1336557216 7c2b27 2:3\n", 0, 50, 60, "2:3"},
+ {"=", -1, 0, 0," "},
+ {"= test", -1, 0, 0," "},
+ {"= test ", -1, 0, 0," "},
+ {"= test 1", -1, 0, 0," "},
+ {"= test 1 ", -1, 0, 0," "},
+ {"= test 1 2", -1, 0, 0," "},
+ {"= test 1 2 ", -1, 0, 0," "},
+ {"= test 1 2 3", -1, 0, 0," "},
+ {NULL, 0, 0, 0,NULL}
};
collie_test *test = node_info_tests;
diff --git a/tests/storagevolxml2xmlin/vol-sheepdog.xml b/tests/storagevolxml2xmlin/vol-sheepdog.xml
index d6e920b..f88e6db 100644
--- a/tests/storagevolxml2xmlin/vol-sheepdog.xml
+++ b/tests/storagevolxml2xmlin/vol-sheepdog.xml
@@ -4,6 +4,7 @@
</source>
<capacity unit='bytes'>1024</capacity>
<allocation unit='bytes'>0</allocation>
+ <redundancy unit='string'>3</redundancy>
<target>
<path>sheepdog:test2</path>
</target>
--
2.5.0
9 years
[libvirt] [PATCH] storage sheepdog: allow to specify redundancy level
by Vasiliy Tolstov
Signed-off-by: Vasiliy Tolstov <v.tolstov(a)selfip.ru>
---
docs/schemas/storagevol.rng | 3 ++
src/conf/storage_conf.c | 2 +
src/storage/storage_backend_sheepdog.c | 38 +++++++++--------
src/util/virstoragefile.c | 4 +-
src/util/virstoragefile.h | 2 +
tests/storagebackendsheepdogtest.c | 68 +++++++++++++++---------------
tests/storagevolxml2xmlin/vol-sheepdog.xml | 1 +
7 files changed, 66 insertions(+), 52 deletions(-)
diff --git a/docs/schemas/storagevol.rng b/docs/schemas/storagevol.rng
index 7450547..068993f 100644
--- a/docs/schemas/storagevol.rng
+++ b/docs/schemas/storagevol.rng
@@ -55,6 +55,9 @@
<element name='allocation'>
<ref name='scaledInteger'/>
</element>
+ <element name='redundancy'>
+ <ref name='string'/>
+ </element>
</optional>
</interleave>
</define>
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 9b8abea..d37c93a 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -1345,6 +1345,8 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
ret->target.allocation = ret->target.capacity;
}
+ ret->target.redundancy = virXPathString("string(./redundancy)", ctxt);
+
ret->target.path = virXPathString("string(./target/path)", ctxt);
if (options->formatFromString) {
char *format = virXPathString("string(./target/format/@type)", ctxt);
diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_backend_sheepdog.c
index 1200813..565cfd0 100644
--- a/src/storage/storage_backend_sheepdog.c
+++ b/src/storage/storage_backend_sheepdog.c
@@ -275,6 +275,10 @@ virStorageBackendSheepdogBuildVol(virConnectPtr conn ATTRIBUTE_UNUSED,
cmd = virCommandNewArgList(SHEEPDOGCLI, "vdi", "create", vol->name, NULL);
virCommandAddArgFormat(cmd, "%llu", vol->target.capacity);
+
+ if(NULL != vol->target.redundancy)
+ virCommandAddArgFormat(cmd, "-c %s", vol->target.redundancy);
+
virStorageBackendSheepdogAddHostArg(cmd, pool);
if (virCommandRun(cmd, NULL) < 0)
goto cleanup;
@@ -291,18 +295,19 @@ virStorageBackendSheepdogParseVdiList(virStorageVolDefPtr vol,
char *output)
{
/* fields:
- * current/clone/snapshot, name, id, size, used, shared, creation time, vdi id, [tag]
+ * current/clone/snapshot, name, id, size, used, shared, creation time, vdi id, redundancy, [tag], size shift
*
* example output:
- * s test 1 10 0 0 1336556634 7c2b25
- * s test 2 10 0 0 1336557203 7c2b26
- * = test 3 10 0 0 1336557216 7c2b27
+ * s test 1 10 0 0 1336556634 7c2b25 1 tt 22
+ * s test 2 10 0 0 1336557203 7c2b26 2 zz 22
+ * = test 3 10 0 0 1336557216 7c2b27 3 xx 22
*/
- int id;
+ char **args;
const char *p, *next;
vol->target.allocation = vol->target.capacity = 0;
+ vol->target.redundancy = NULL;
p = output;
do {
@@ -327,24 +332,21 @@ virStorageBackendSheepdogParseVdiList(virStorageVolDefPtr vol,
++p;
++p;
}
+ }
+ args = virStringSplit(p, " ", 9);
- if (virStrToLong_i(p, &end, 10, &id) < 0)
- return -1;
-
- p = end + 1;
-
- if (virStrToLong_ull(p, &end, 10, &vol->target.capacity) < 0)
- return -1;
+ if (virStrToLong_ull(args[1], strlen(args[1]), 10, &vol->target.capacity) < 0)
+ return -1;
- p = end + 1;
+ if (virStrToLong_ull(args[2], strlen(args[2]), 10, &vol->target.allocation) < 0)
+ return -1;
- if (virStrToLong_ull(p, &end, 10, &vol->target.allocation) < 0)
- return -1;
+ if (VIR_STRNDUP(vol->target.redundancy, args[5], strlen(args[2])) < 0)
+ return -1;
- return 0;
- } while ((p = next));
+ virStringFreeList(args);
- return -1;
+ return 0;
}
static int
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 2aa1d90..9cdc90d 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -1846,7 +1846,8 @@ virStorageSourceCopy(const virStorageSource *src,
VIR_STRDUP(ret->backingStoreRaw, src->backingStoreRaw) < 0 ||
VIR_STRDUP(ret->snapshot, src->snapshot) < 0 ||
VIR_STRDUP(ret->configFile, src->configFile) < 0 ||
- VIR_STRDUP(ret->compat, src->compat) < 0)
+ VIR_STRDUP(ret->compat, src->compat) < 0 ||
+ VIR_STRDUP(ret->redundancy, src->redundancy) < 0)
goto error;
if (src->nhosts) {
@@ -2040,6 +2041,7 @@ virStorageSourceClear(virStorageSourcePtr def)
VIR_FREE(def->volume);
VIR_FREE(def->snapshot);
VIR_FREE(def->configFile);
+ VIR_FREE(def->redundancy);
virStorageSourcePoolDefFree(def->srcpool);
VIR_FREE(def->driverName);
virBitmapFree(def->features);
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index b98fe25..c37cfc2 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -282,6 +282,8 @@ struct _virStorageSource {
/* Name of the child backing store recorded in metadata of the
* current file. */
char *backingStoreRaw;
+ /* redundancy level, may be used by sheepdog or ceph */
+ char *redundancy;
};
diff --git a/tests/storagebackendsheepdogtest.c b/tests/storagebackendsheepdogtest.c
index 2b0f4db..c037ebe 100644
--- a/tests/storagebackendsheepdogtest.c
+++ b/tests/storagebackendsheepdogtest.c
@@ -42,6 +42,7 @@ typedef struct {
int expected_return;
uint64_t expected_capacity;
uint64_t expected_allocation;
+ const char *expected_redundancy;
} collie_test;
struct testNodeInfoParserData {
@@ -119,7 +120,8 @@ test_vdi_list_parser(const void *opaque)
}
if (vol->target.capacity == test.expected_capacity &&
- vol->target.allocation == test.expected_allocation)
+ vol->target.allocation == test.expected_allocation &&
+ !strcmp(vol->target.redundancy, test.expected_redundancy))
ret = 0;
cleanup:
@@ -138,41 +140,41 @@ mymain(void)
char *volxml = NULL;
collie_test node_info_tests[] = {
- {"", -1, 0, 0},
- {"Total 15245667872 117571104 0% 20972341\n", 0, 15245667872, 117571104},
- {"To", -1, 0, 0},
- {"asdf\nasdf", -1, 0, 0},
- {"Total ", -1, 0, 0},
- {"Total 1", -1, 0, 0},
- {"Total 1\n", -1, 0, 0},
- {"Total 1 ", -1, 0, 0},
- {"Total 1 2", -1, 0, 0},
- {"Total 1 2 ", -1, 0, 0},
- {"Total 1 2\n", 0, 1, 2},
- {"Total 1 2 \n", 0, 1, 2},
- {"Total a 2 \n", -1, 0, 0},
- {"Total 1 b \n", -1, 0, 0},
- {"Total a b \n", -1, 0, 0},
- {"stuff\nTotal 1 2 \n", 0, 1, 2},
- {"0 1 2 3\nTotal 1 2 \n", 0, 1, 2},
- {NULL, 0, 0, 0}
+ {"", -1, 0, 0,"0"},
+ {"Total 15245667872 117571104 1 0% 20972341\n", 0, 15245667872, 117571104,"1"},
+ {"To", -1, 0, 0," "},
+ {"asdf\nasdf", -1, 0, 0," "},
+ {"Total ", -1, 0, 0, " "},
+ {"Total 1", -1, 0, 0, " "},
+ {"Total 1\n", -1, 0, 0," "},
+ {"Total 1 ", -1, 0, 0, " "},
+ {"Total 1 2", -1, 0, 0, " "},
+ {"Total 1 2 ", -1, 0, 0," "},
+ {"Total 1 2 1:1\n", 0, 1, 2,"1:1"},
+ {"Total 1 2 3:4\n", 0, 1, 2,"3:4"},
+ {"Total a 2 \n", -1, 0, 0," "},
+ {"Total 1 b \n", -1, 0, 0," "},
+ {"Total a b \n", -1, 0, 0,"sss"},
+ {"stuff\nTotal 1 2 1:2\n", 0, 1, 2,"1:2"},
+ {"0 1 2 3\nTotal 1 2 3\n", 0, 1, 2,"3"},
+ {NULL, 0, 0, 0, NULL}
};
collie_test vdi_list_tests[] = {
- {"", -1, 0, 0},
- {"= test 3 10 20 0 1336557216 7c2b27\n", 0, 10, 20},
- {"= test\\ with\\ spaces 3 10 20 0 1336557216 7c2b27\n", 0, 10, 20},
- {"= backslashattheend\\\\ 3 10 20 0 1336557216 7c2b27\n", 0, 10, 20},
- {"s test 1 10 20 0 1336556634 7c2b25\n= test 3 50 60 0 1336557216 7c2b27\n", 0, 50, 60},
- {"=", -1, 0, 0},
- {"= test", -1, 0, 0},
- {"= test ", -1, 0, 0},
- {"= test 1", -1, 0, 0},
- {"= test 1 ", -1, 0, 0},
- {"= test 1 2", -1, 0, 0},
- {"= test 1 2 ", -1, 0, 0},
- {"= test 1 2 3", -1, 0, 0},
- {NULL, 0, 0, 0}
+ {"", -1, 0, 0,NULL},
+ {"= test 3 10 20 1 0 1336557216 7c2b27 1\n", 0, 10, 20, "1"},
+ {"= test\\ with\\ spaces 3 10 20 0 1336557216 7c2b27 3:4\n", 0, 10, 20, "3:4"},
+ {"= backslashattheend\\\\ 3 10 20 0 1336557216 7c2b27 1\n", 0, 10, 20, "1"},
+ {"s test 1 10 20 0 1336556634 7c2b25 2\n= test 3 50 60 0 1336557216 7c2b27 2:3\n", 0, 50, 60, "2:3"},
+ {"=", -1, 0, 0," "},
+ {"= test", -1, 0, 0," "},
+ {"= test ", -1, 0, 0," "},
+ {"= test 1", -1, 0, 0," "},
+ {"= test 1 ", -1, 0, 0," "},
+ {"= test 1 2", -1, 0, 0," "},
+ {"= test 1 2 ", -1, 0, 0," "},
+ {"= test 1 2 3", -1, 0, 0," "},
+ {NULL, 0, 0, 0,NULL}
};
collie_test *test = node_info_tests;
diff --git a/tests/storagevolxml2xmlin/vol-sheepdog.xml b/tests/storagevolxml2xmlin/vol-sheepdog.xml
index d6e920b..f88e6db 100644
--- a/tests/storagevolxml2xmlin/vol-sheepdog.xml
+++ b/tests/storagevolxml2xmlin/vol-sheepdog.xml
@@ -4,6 +4,7 @@
</source>
<capacity unit='bytes'>1024</capacity>
<allocation unit='bytes'>0</allocation>
+ <redundancy unit='string'>3</redundancy>
<target>
<path>sheepdog:test2</path>
</target>
--
2.5.0
9 years