[libvirt] [PATCH] Do a correct format mapping of partitions
by Henrik Persson E
This patch reads the partition type and sets the correct target format
of the storage volume when based on physical disk.
--- libvirt-0.6.4.org/src/parthelper.c 2008-09-02 11:24:21.000000000
+0200
+++ libvirt-0.6.4/src/parthelper.c 2009-06-22 16:29:49.108681000
+0200
@@ -67,6 +67,7 @@
while (part) {
const char *type;
const char *content;
+ int partType = 0;
if (part->type & PED_PARTITION_LOGICAL) {
type = "logical";
if (part->type & PED_PARTITION_FREESPACE)
@@ -92,26 +93,35 @@
content = "data";
}
+ /* Get partition type */
+ if(ped_partition_is_active(part)) {
+ if(ped_partition_is_flag_available(part,
PED_PARTITION_TYPE)) {
+ partType =
ped_partition_get_flag(part,PED_PARTITION_TYPE);
+ }
+ }
+
/* We do +1 on geom.end, because we want end of the last sector
* in bytes, not the last sector number
*/
if (part->num != -1) {
- printf("%s%d%c%s%c%s%c%llu%c%llu%c%llu%c",
+ printf("%s%d%c%s%c%s%c%llu%c%llu%c%llu%c%d%c",
part->geom.dev->path,
part->num, '\0',
type, '\0',
content, '\0',
part->geom.start * 512llu, '\0',
(part->geom.end + 1 ) * 512llu, '\0',
- part->geom.length * 512llu, '\0');
+ part->geom.length * 512llu, '\0',
+ partType, '\0');
} else {
- printf("%s%c%s%c%s%c%llu%c%llu%c%llu%c",
+ printf("%s%c%s%c%s%c%llu%c%llu%c%llu%c%d%c",
"-", '\0',
type, '\0',
content, '\0',
part->geom.start * 512llu, '\0',
(part->geom.end + 1 ) * 512llu, '\0',
- part->geom.length * 512llu, '\0');
+ part->geom.length * 512llu, '\0',
+ partType, '\0');
}
part = ped_disk_next_partition(disk, part);
}
--- libvirt-0.6.4.org/src/storage_backend_disk.c 2009-04-02
11:50:10.000000000 +0200
+++ libvirt-0.6.4/src/storage_backend_disk.c 2009-06-22
18:25:14.095095000 +0200
@@ -36,6 +36,35 @@
#define PARTHELPER BINDIR "/libvirt_parthelper"
+/* Map partition types to internal enum */
+static int
+virStorageBackendDiskMapPartitionType(const char* partType)
+{
+ switch(atoi(partType)) {
+ case 0x05:
+ case 0x0f:
+ return VIR_STORAGE_VOL_DISK_EXTENDED;
+ case 0x06:
+ case 0x0e:
+ return VIR_STORAGE_VOL_DISK_FAT16;
+ case 0x0b:
+ case 0x0c:
+ return VIR_STORAGE_VOL_DISK_FAT32;
+ case 0x82:
+ return VIR_STORAGE_VOL_DISK_LINUX_SWAP;
+ case 0x83:
+ return VIR_STORAGE_VOL_DISK_LINUX;
+ case 0x8e:
+ return VIR_STORAGE_VOL_DISK_LINUX_LVM;
+ case 0xfd:
+ return VIR_STORAGE_VOL_DISK_LINUX_RAID;
+ default:
+ return VIR_STORAGE_VOL_DISK_NONE;
+
+ }
+}
+
+
static int
virStorageBackendDiskMakeDataVol(virConnectPtr conn,
virStoragePoolObjPtr pool,
@@ -128,6 +157,9 @@
if (virStorageBackendUpdateVolInfo(conn, vol, 1) < 0)
return -1;
+ /* virStorageBackendUpdateVolInfo sets format incorrect for
partitions */
+ vol->target.format =
virStorageBackendDiskMapPartitionType(groups[6]);
+
vol->type = VIR_STORAGE_VOL_BLOCK;
/* The above gets allocation wrong for
@@ -250,7 +282,7 @@
return virStorageBackendRunProgNul(conn,
pool,
prog,
- 6,
+ 7,
virStorageBackendDiskMakeVol,
vol);
}
15 years, 5 months
[libvirt] virsh -no-kvm problem on debian install
by ChaosMedia > WebDev
Hi,
i've installed lastest kvm-86 and libvirt-0.6.4 tarballs on my debian
stable and have a problem using virsh
No matter what i do in the guest domain config or with /usr/bin/
symlinks, libvirt keeps using the -no-kvm option when starting guests
when my cpu has kvm-amd support, modules are loaded and /dev/kvm exists,
and starting the guests thru command line works fine, and faster.
debian seems to install the following binary
/usr/bin/qemu-system-x86_64, i had to add "/usr/bin/qemu" to get virsh
to work, otherwise it will say it can't connect to qemu:///system
here's some command output :
#virsh -c qemu:///system capabilities
<capabilities>
<host>
<cpu>
<arch>x86_64</arch>
</cpu>
<migration_features>
<live/>
<uri_transports>
<uri_transport>tcp</uri_transport>
</uri_transports>
</migration_features>
</host>
<guest>
<os_type>hvm</os_type>
<arch name='i686'>
<wordsize>32</wordsize>
<emulator>/usr/bin/qemu</emulator>
<machine>pc</machine>
<machine>isapc</machine>
<domain type='qemu'>
</domain>
</arch>
<features>
<pae/>
<nonpae/>
<acpi default='on' toggle='yes'/>
<apic default='on' toggle='no'/>
</features>
</guest>
<guest>
<os_type>hvm</os_type>
<arch name='x86_64'>
<wordsize>64</wordsize>
<emulator>/usr/bin/qemu-system-x86_64</emulator>
<machine>pc</machine>
<machine>isapc</machine>
<domain type='qemu'>
</domain>
</arch>
<features>
<acpi default='on' toggle='yes'/>
<apic default='on' toggle='no'/>
</features>
</guest>
</capabilities>
and tried adding "/usr/bin/qemu-kvm" symlink
<capabilities>
<host>
<cpu>
<arch>x86_64</arch>
</cpu>
<migration_features>
<live/>
<uri_transports>
<uri_transport>tcp</uri_transport>
</uri_transports>
</migration_features>
</host>
<guest>
<os_type>hvm</os_type>
<arch name='i686'>
<wordsize>32</wordsize>
<emulator>/usr/bin/qemu</emulator>
<machine>pc</machine>
<machine>isapc</machine>
<domain type='qemu'>
</domain>
<domain type='kvm'>
<emulator>/usr/bin/qemu-kvm</emulator>
</domain>
</arch>
<features>
<pae/>
<nonpae/>
<acpi default='on' toggle='yes'/>
<apic default='on' toggle='no'/>
</features>
</guest>
<guest>
<os_type>hvm</os_type>
<arch name='x86_64'>
<wordsize>64</wordsize>
<emulator>/usr/bin/qemu-system-x86_64</emulator>
<machine>pc</machine>
<machine>isapc</machine>
<domain type='qemu'>
</domain>
<domain type='kvm'>
<emulator>/usr/bin/qemu-kvm</emulator>
</domain>
</arch>
<features>
<acpi default='on' toggle='yes'/>
<apic default='on' toggle='no'/>
</features>
</guest>
</capabilities>
So far i had no luck getting virsh to use kvm, it always adds the
-no-kvm option, i'm not sure how to specify the domain type in the guest
config, using the <emulator>/usr/bin/qemu-kvm</emulator> won't help.
i've found that thread discussing the binaries and options but don't
know if that patch was already added or if i have to patch my tarball..
http://www.redhat.com/archives/libvir-list/2009-March/msg00281.html
please let me know if there's some way to let libvirt know that kvm
exists on a debian install, using /usr/bin/qemu-system-x86_64
thx,
Marc
15 years, 5 months
[libvirt] [RFC] Reporting host interface status/statistics via netcf/libvirt, and listing active vs. inactive interfaces
by Laine Stump
I've already been working on incorporating physical host interface
configuration into libvirt by way of using libnetcf on the backend. It's
becoming apparent that, in addition to modifying and reporting the
current configuration of interfaces, libvirt users also want to query
current status of each interface (up/down, possibly other flags,
packet/byte/error counts, current IP address, etc).
There are two possible ways of doing this:
1) maintain libnetcf's focus on just interface configuration, and
add code directly into libvirt to grab this information via
appropriate ioctls
or
2) add the functionality to libnetcf, and have libvirt call the
new libnetcf API.
(2) seems to make the most sense, because likely other libnetcf
consumers will want this capability too.
I'm thinking of a single API, something like:
int netcf_if_status(netcf_if *, netcf_if_stats *);
(or maybe int netcf_if_info(netcf_if *, netcf_if_info *))
I haven't really put much thought into the details of what should be in
netcf_if_stats yet (beyond what I listed above), but wanted to get this
idea out there so people can start sounding off (if I'm going down the
wrong road, I'd rather be put on the right path before I get too far along!)
This function could be exposed in the libvirt API as something like:
int virInterfaceStatus|Info(virInterffacePtr iface,
virInterfaceStats|Info *info);
Any comments/ideas on this?
(One possible complication I can see is interfaces with multiple
associated IPs. On some platforms, each interface can have only a single
IPv4 and a single IPv6 address (more IPs == more interfaces), but on
others there can be multiples.)
A (kind of) separate issue: In libvirt we want to be able to list active
(up) and inactive (down) interfaces separately. For consistency,
libvirt's way of exposing that will be to mimic what is done with
virConnectListNetworks() (active) vs. virConnectListDefinedNetworks()
(inactive).
But netcf could do it with an extra argument to ncf_list_interfaces().
If the latter, should the default behavior be to list all interfaces,
with flags set to eliminate up or down interfaces?
0 (list all)
NETCF_NOLIST_UP
NETCF_NOLIST_DOWN
Or should the values be something like this:
0 (list all)
NETCF_LIST_UP_ONLY
NETCF_LIST_DOWN_ONLY
(UP_ONLY + DOWN_ONLY would be equivalent to 0. As long as nobody came up
with a good reason for "0".
So should we do one of those, or should we mimic libirt's virNetwork API
in libnetcf too?
15 years, 5 months
[libvirt] [PATCH] Refactor storage XML parsing to be consistent with domain/network conf.
by Cole Robinson
The storage driver arranges its parsing routines in a way that make them
difficult to use in the test driver for non-default file parsing. This
refactoring moves things to be consistent with the way domain_conf and
network_conf do things.
Signed-off-by: Cole Robinson <crobinso(a)redhat.com>
---
src/libvirt_private.syms | 8 ++-
src/storage_conf.c | 163 ++++++++++++++++++++++++++++++++--------------
src/storage_conf.h | 26 ++++++--
src/storage_driver.c | 8 +-
src/test.c | 25 ++-----
5 files changed, 150 insertions(+), 80 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index f63fa05..309d7f9 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -267,7 +267,9 @@ virSecurityDriverGetModel;
# storage_conf.h
virStoragePoolDefFormat;
virStoragePoolDefFree;
-virStoragePoolDefParse;
+virStoragePoolDefParseString;
+virStoragePoolDefParseFile;
+virStoragePoolDefParseNode;
virStoragePoolLoadAllConfigs;
virStoragePoolObjAssignDef;
virStoragePoolObjClearVols;
@@ -284,7 +286,9 @@ virStorageVolDefFindByName;
virStorageVolDefFindByPath;
virStorageVolDefFormat;
virStorageVolDefFree;
-virStorageVolDefParse;
+virStorageVolDefParseFile;
+virStorageVolDefParseString;
+virStorageVolDefParseNode;
virStoragePoolFormatDiskTypeToString;
virStoragePoolFormatFileSystemTypeToString;
virStoragePoolFormatFileSystemNetTypeToString;
diff --git a/src/storage_conf.c b/src/storage_conf.c
index 5f724dc..7d495ec 100644
--- a/src/storage_conf.c
+++ b/src/storage_conf.c
@@ -452,14 +452,12 @@ error:
return ret;
}
-
static virStoragePoolDefPtr
-virStoragePoolDefParseDoc(virConnectPtr conn,
- xmlXPathContextPtr ctxt,
- xmlNodePtr root) {
+virStoragePoolDefParseXML(virConnectPtr conn,
+ xmlXPathContextPtr ctxt) {
virStoragePoolOptionsPtr options;
virStoragePoolDefPtr ret;
- xmlChar *type = NULL;
+ char *type = NULL;
char *uuid = NULL;
char *authType = NULL;
@@ -468,13 +466,7 @@ virStoragePoolDefParseDoc(virConnectPtr conn,
return NULL;
}
- if (STRNEQ((const char *)root->name, "pool")) {
- virStorageReportError(conn, VIR_ERR_XML_ERROR,
- "%s", _("unknown root element for storage pool"));
- goto cleanup;
- }
-
- type = xmlGetProp(root, BAD_CAST "type");
+ type = virXPathString(conn, "string(./@type)", ctxt);
if ((ret->type = virStoragePoolTypeFromString((const char *)type)) < 0) {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
_("unknown storage pool type %s"), (const char*)type);
@@ -656,6 +648,32 @@ catchXMLError (void *ctx, const char *msg ATTRIBUTE_UNUSED, ...)
}
virStoragePoolDefPtr
+virStoragePoolDefParseNode(virConnectPtr conn,
+ xmlDocPtr xml,
+ xmlNodePtr root) {
+ xmlXPathContextPtr ctxt = NULL;
+ virStoragePoolDefPtr def = NULL;
+
+ if (STRNEQ((const char *)root->name, "pool")) {
+ virStorageReportError(conn, VIR_ERR_XML_ERROR,
+ "%s", _("unknown root element for storage pool"));
+ goto cleanup;
+ }
+
+ ctxt = xmlXPathNewContext(xml);
+ if (ctxt == NULL) {
+ virReportOOMError(conn);
+ goto cleanup;
+ }
+
+ ctxt->node = root;
+ def = virStoragePoolDefParseXML(conn, ctxt);
+cleanup:
+ xmlXPathFreeContext(ctxt);
+ return def;
+}
+
+static virStoragePoolDefPtr
virStoragePoolDefParse(virConnectPtr conn,
const char *xmlStr,
const char *filename) {
@@ -663,7 +681,6 @@ virStoragePoolDefParse(virConnectPtr conn,
xmlParserCtxtPtr pctxt;
xmlDocPtr xml = NULL;
xmlNodePtr node = NULL;
- xmlXPathContextPtr ctxt = NULL;
/* Set up a parser context so we can catch the details of XML errors. */
pctxt = xmlNewParserCtxt ();
@@ -673,10 +690,17 @@ virStoragePoolDefParse(virConnectPtr conn,
pctxt->_private = conn;
if (conn) virResetError (&conn->err);
- xml = xmlCtxtReadDoc (pctxt, BAD_CAST xmlStr,
- filename ? filename : "storage.xml", NULL,
- XML_PARSE_NOENT | XML_PARSE_NONET |
- XML_PARSE_NOWARNING);
+ if (filename) {
+ xml = xmlCtxtReadFile (pctxt, filename, NULL,
+ XML_PARSE_NOENT | XML_PARSE_NONET |
+ XML_PARSE_NOWARNING);
+ } else {
+ xml = xmlCtxtReadDoc (pctxt, BAD_CAST xmlStr,
+ "storage.xml", NULL,
+ XML_PARSE_NOENT | XML_PARSE_NONET |
+ XML_PARSE_NOWARNING);
+ }
+
if (!xml) {
if (conn && conn->err.code == VIR_ERR_NONE)
virStorageReportError(conn, VIR_ERR_XML_ERROR,
@@ -684,12 +708,6 @@ virStoragePoolDefParse(virConnectPtr conn,
goto cleanup;
}
- ctxt = xmlXPathNewContext(xml);
- if (ctxt == NULL) {
- virReportOOMError(conn);
- goto cleanup;
- }
-
node = xmlDocGetRootElement(xml);
if (node == NULL) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
@@ -697,21 +715,33 @@ virStoragePoolDefParse(virConnectPtr conn,
goto cleanup;
}
- ret = virStoragePoolDefParseDoc(conn, ctxt, node);
+ ret = virStoragePoolDefParseNode(conn, xml, node);
xmlFreeParserCtxt (pctxt);
- xmlXPathFreeContext(ctxt);
xmlFreeDoc(xml);
return ret;
cleanup:
xmlFreeParserCtxt (pctxt);
- xmlXPathFreeContext(ctxt);
xmlFreeDoc(xml);
return NULL;
}
+virStoragePoolDefPtr
+virStoragePoolDefParseString(virConnectPtr conn,
+ const char *xmlStr)
+{
+ return virStoragePoolDefParse(conn, xmlStr, NULL);
+}
+
+virStoragePoolDefPtr
+virStoragePoolDefParseFile(virConnectPtr conn,
+ const char *filename)
+{
+ return virStoragePoolDefParse(conn, NULL, filename);
+}
+
static int
virStoragePoolSourceFormat(virConnectPtr conn,
virBufferPtr buf,
@@ -916,10 +946,9 @@ virStorageSize(virConnectPtr conn,
}
static virStorageVolDefPtr
-virStorageVolDefParseDoc(virConnectPtr conn,
+virStorageVolDefParseXML(virConnectPtr conn,
virStoragePoolDefPtr pool,
- xmlXPathContextPtr ctxt,
- xmlNodePtr root) {
+ xmlXPathContextPtr ctxt) {
virStorageVolDefPtr ret;
virStorageVolOptionsPtr options;
char *allocation = NULL;
@@ -935,12 +964,6 @@ virStorageVolDefParseDoc(virConnectPtr conn,
return NULL;
}
- if (STRNEQ((const char *)root->name, "volume")) {
- virStorageReportError(conn, VIR_ERR_XML_ERROR,
- "%s", _("unknown root element"));
- goto cleanup;
- }
-
ret->name = virXPathString(conn, "string(/volume/name)", ctxt);
if (ret->name == NULL) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
@@ -1028,8 +1051,34 @@ virStorageVolDefParseDoc(virConnectPtr conn,
return NULL;
}
-
virStorageVolDefPtr
+virStorageVolDefParseNode(virConnectPtr conn,
+ virStoragePoolDefPtr pool,
+ xmlDocPtr xml,
+ xmlNodePtr root) {
+ xmlXPathContextPtr ctxt = NULL;
+ virStorageVolDefPtr def = NULL;
+
+ if (STRNEQ((const char *)root->name, "volume")) {
+ virStorageReportError(conn, VIR_ERR_XML_ERROR,
+ "%s", _("unknown root element for storage vol"));
+ goto cleanup;
+ }
+
+ ctxt = xmlXPathNewContext(xml);
+ if (ctxt == NULL) {
+ virReportOOMError(conn);
+ goto cleanup;
+ }
+
+ ctxt->node = root;
+ def = virStorageVolDefParseXML(conn, pool, ctxt);
+cleanup:
+ xmlXPathFreeContext(ctxt);
+ return def;
+}
+
+static virStorageVolDefPtr
virStorageVolDefParse(virConnectPtr conn,
virStoragePoolDefPtr pool,
const char *xmlStr,
@@ -1038,7 +1087,6 @@ virStorageVolDefParse(virConnectPtr conn,
xmlParserCtxtPtr pctxt;
xmlDocPtr xml = NULL;
xmlNodePtr node = NULL;
- xmlXPathContextPtr ctxt = NULL;
/* Set up a parser context so we can catch the details of XML errors. */
pctxt = xmlNewParserCtxt ();
@@ -1048,10 +1096,18 @@ virStorageVolDefParse(virConnectPtr conn,
pctxt->_private = conn;
if (conn) virResetError (&conn->err);
- xml = xmlCtxtReadDoc (pctxt, BAD_CAST xmlStr,
- filename ? filename : "storage.xml", NULL,
- XML_PARSE_NOENT | XML_PARSE_NONET |
- XML_PARSE_NOWARNING);
+
+ if (filename) {
+ xml = xmlCtxtReadFile (pctxt, filename, NULL,
+ XML_PARSE_NOENT | XML_PARSE_NONET |
+ XML_PARSE_NOWARNING);
+ } else {
+ xml = xmlCtxtReadDoc (pctxt, BAD_CAST xmlStr,
+ "storage.xml", NULL,
+ XML_PARSE_NOENT | XML_PARSE_NONET |
+ XML_PARSE_NOWARNING);
+ }
+
if (!xml) {
if (conn && conn->err.code == VIR_ERR_NONE)
virStorageReportError(conn, VIR_ERR_XML_ERROR,
@@ -1059,12 +1115,6 @@ virStorageVolDefParse(virConnectPtr conn,
goto cleanup;
}
- ctxt = xmlXPathNewContext(xml);
- if (ctxt == NULL) {
- virReportOOMError(conn);
- goto cleanup;
- }
-
node = xmlDocGetRootElement(xml);
if (node == NULL) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
@@ -1072,21 +1122,34 @@ virStorageVolDefParse(virConnectPtr conn,
goto cleanup;
}
- ret = virStorageVolDefParseDoc(conn, pool, ctxt, node);
+ ret = virStorageVolDefParseNode(conn, pool, xml, node);
xmlFreeParserCtxt (pctxt);
- xmlXPathFreeContext(ctxt);
xmlFreeDoc(xml);
return ret;
cleanup:
xmlFreeParserCtxt (pctxt);
- xmlXPathFreeContext(ctxt);
xmlFreeDoc(xml);
return NULL;
}
+virStorageVolDefPtr
+virStorageVolDefParseString(virConnectPtr conn,
+ virStoragePoolDefPtr pool,
+ const char *xmlStr)
+{
+ return virStorageVolDefParse(conn, pool, xmlStr, NULL);
+}
+
+virStorageVolDefPtr
+virStorageVolDefParseFile(virConnectPtr conn,
+ virStoragePoolDefPtr pool,
+ const char *filename)
+{
+ return virStorageVolDefParse(conn, pool, NULL, filename);
+}
static int
virStorageVolTargetDefFormat(virConnectPtr conn,
diff --git a/src/storage_conf.h b/src/storage_conf.h
index 8a4fed2..a2a164e 100644
--- a/src/storage_conf.h
+++ b/src/storage_conf.h
@@ -28,6 +28,8 @@
#include "util.h"
#include "threads.h"
+#include <libxml/tree.h>
+
/* Shared structs */
@@ -306,16 +308,26 @@ virStorageVolDefPtr virStorageVolDefFindByName(virStoragePoolObjPtr pool,
void virStoragePoolObjClearVols(virStoragePoolObjPtr pool);
-virStoragePoolDefPtr virStoragePoolDefParse(virConnectPtr conn,
- const char *xml,
- const char *filename);
+virStoragePoolDefPtr virStoragePoolDefParseString(virConnectPtr conn,
+ const char *xml);
+virStoragePoolDefPtr virStoragePoolDefParseFile(virConnectPtr conn,
+ const char *filename);
+virStoragePoolDefPtr virStoragePoolDefParseNode(virConnectPtr conn,
+ xmlDocPtr xml,
+ xmlNodePtr root);
char *virStoragePoolDefFormat(virConnectPtr conn,
virStoragePoolDefPtr def);
-virStorageVolDefPtr virStorageVolDefParse(virConnectPtr conn,
- virStoragePoolDefPtr pool,
- const char *xml,
- const char *filename);
+virStorageVolDefPtr virStorageVolDefParseString(virConnectPtr conn,
+ virStoragePoolDefPtr pool,
+ const char *xml);
+virStorageVolDefPtr virStorageVolDefParseFile(virConnectPtr conn,
+ virStoragePoolDefPtr pool,
+ const char *filename);
+virStorageVolDefPtr virStorageVolDefParseNode(virConnectPtr conn,
+ virStoragePoolDefPtr pool,
+ xmlDocPtr xml,
+ xmlNodePtr root);
char *virStorageVolDefFormat(virConnectPtr conn,
virStoragePoolDefPtr pool,
virStorageVolDefPtr def);
diff --git a/src/storage_driver.c b/src/storage_driver.c
index 5a248a3..5fe22c6 100644
--- a/src/storage_driver.c
+++ b/src/storage_driver.c
@@ -466,7 +466,7 @@ storagePoolCreate(virConnectPtr conn,
virStorageBackendPtr backend;
storageDriverLock(driver);
- if (!(def = virStoragePoolDefParse(conn, xml, NULL)))
+ if (!(def = virStoragePoolDefParseString(conn, xml)))
goto cleanup;
pool = virStoragePoolObjFindByUUID(&driver->pools, def->uuid);
@@ -518,7 +518,7 @@ storagePoolDefine(virConnectPtr conn,
virStorageBackendPtr backend;
storageDriverLock(driver);
- if (!(def = virStoragePoolDefParse(conn, xml, NULL)))
+ if (!(def = virStoragePoolDefParseString(conn, xml)))
goto cleanup;
if ((backend = virStorageBackendForType(def->type)) == NULL)
@@ -1220,7 +1220,7 @@ storageVolumeCreateXML(virStoragePoolPtr obj,
if ((backend = virStorageBackendForType(pool->def->type)) == NULL)
goto cleanup;
- voldef = virStorageVolDefParse(obj->conn, pool->def, xmldesc, NULL);
+ voldef = virStorageVolDefParseString(obj->conn, pool->def, xmldesc);
if (voldef == NULL)
goto cleanup;
@@ -1362,7 +1362,7 @@ storageVolumeCreateXMLFrom(virStoragePoolPtr obj,
goto cleanup;
}
- newvol = virStorageVolDefParse(obj->conn, pool->def, xmldesc, NULL);
+ newvol = virStorageVolDefParseString(obj->conn, pool->def, xmldesc);
if (newvol == NULL)
goto cleanup;
diff --git a/src/test.c b/src/test.c
index 2a672a3..6874d63 100644
--- a/src/test.c
+++ b/src/test.c
@@ -286,7 +286,7 @@ static int testOpenDefault(virConnectPtr conn) {
netobj->persistent = 1;
virNetworkObjUnlock(netobj);
- if (!(pooldef = virStoragePoolDefParse(conn, defaultPoolXML, NULL)))
+ if (!(pooldef = virStoragePoolDefParseString(conn, defaultPoolXML)))
goto error;
if (!(poolobj = virStoragePoolObjAssignDef(conn, &privconn->pools,
@@ -564,22 +564,13 @@ static int testOpenFromFile(virConnectPtr conn,
goto error;
}
- def = virStoragePoolDefParse(conn, NULL, absFile);
+ def = virStoragePoolDefParseFile(conn, absFile);
VIR_FREE(absFile);
if (!def)
goto error;
} else {
- xmlBufferPtr buf;
- xmlSaveCtxtPtr sctxt;
-
- buf = xmlBufferCreate();
- sctxt = xmlSaveToBuffer(buf, NULL, 0);
- xmlSaveTree(sctxt, pools[i]);
- xmlSaveClose(sctxt);
- if ((def = virStoragePoolDefParse(conn,
- (const char *) buf->content,
- NULL)) == NULL) {
- xmlBufferFree(buf);
+ if ((def = virStoragePoolDefParseNode(conn, xml,
+ pools[i])) == NULL) {
goto error;
}
}
@@ -2514,7 +2505,7 @@ testStoragePoolCreate(virConnectPtr conn,
virStoragePoolPtr ret = NULL;
testDriverLock(privconn);
- if (!(def = virStoragePoolDefParse(conn, xml, NULL)))
+ if (!(def = virStoragePoolDefParseString(conn, xml)))
goto cleanup;
pool = virStoragePoolObjFindByUUID(&privconn->pools, def->uuid);
@@ -2557,7 +2548,7 @@ testStoragePoolDefine(virConnectPtr conn,
virStoragePoolPtr ret = NULL;
testDriverLock(privconn);
- if (!(def = virStoragePoolDefParse(conn, xml, NULL)))
+ if (!(def = virStoragePoolDefParseString(conn, xml)))
goto cleanup;
def->capacity = defaultPoolCap;
@@ -3082,7 +3073,7 @@ testStorageVolumeCreateXML(virStoragePoolPtr pool,
goto cleanup;
}
- privvol = virStorageVolDefParse(pool->conn, privpool->def, xmldesc, NULL);
+ privvol = virStorageVolDefParseString(pool->conn, privpool->def, xmldesc);
if (privvol == NULL)
goto cleanup;
@@ -3163,7 +3154,7 @@ testStorageVolumeCreateXMLFrom(virStoragePoolPtr pool,
goto cleanup;
}
- privvol = virStorageVolDefParse(pool->conn, privpool->def, xmldesc, NULL);
+ privvol = virStorageVolDefParseString(pool->conn, privpool->def, xmldesc);
if (privvol == NULL)
goto cleanup;
--
1.6.3.2
15 years, 5 months
[libvirt] [PATCH] Fix raw storage volume creation for allocation < capacity.
by Cole Robinson
CreateXMLFrom changes accidentally caused all raw volume creation to be
fully allocated (as though allocation == capacity). Fix this.
Also force CreateXMLFrom to maintain the previous behavior: sparseness
should still be maintained since we search for holes when copying, and the
clone behavior hasn't been tested with anything but the broken behavior.
Signed-off-by: Cole Robinson <crobinso(a)redhat.com>
---
src/storage_backend_fs.c | 2 +-
src/storage_driver.c | 5 +++++
2 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/src/storage_backend_fs.c b/src/storage_backend_fs.c
index 0e93e54..c3d66b5 100644
--- a/src/storage_backend_fs.c
+++ b/src/storage_backend_fs.c
@@ -1047,7 +1047,7 @@ static int createRaw(virConnectPtr conn,
goto cleanup;
}
- remain = vol->capacity;
+ remain = vol->allocation;
if (inputfd != -1) {
int amtread = -1;
diff --git a/src/storage_driver.c b/src/storage_driver.c
index 71e64a4..57a93c1 100644
--- a/src/storage_driver.c
+++ b/src/storage_driver.c
@@ -1377,6 +1377,11 @@ storageVolumeCreateXMLFrom(virStoragePoolPtr obj,
if (newvol->capacity < origvol->capacity)
newvol->capacity = origvol->capacity;
+ /* Make sure allocation is at least as large as the destination cap,
+ * to make absolutely sure we copy all possible contents */
+ if (newvol->allocation < origvol->capacity;
+ newvol->allocation = origvol->capacity;
+
if (!backend->buildVolFrom) {
virStorageReportError(obj->conn, VIR_ERR_NO_SUPPORT,
"%s", _("storage pool does not support volume creation from an existing volume"));
--
1.6.0.6
15 years, 5 months
[libvirt] Storage volume issues when creating an LVM or RAID partition
by Henrik Persson E
Hi everyone,
I have currently some patches coming up for storage pools and volumes
based on physical disks. However I have an issue that I would like to
hear your opinion about.
When it comes to storage pools and volumes based on physical disks, the
name given does not really have any real meaning, the underlying
disk/partition will at the end decide the name of the pool/volume (as
soon as a refresh on the pool is made, the user defined names will be
gone). This is quite confusion but at the end it still works. But there
are cases where it does not work.
To be able to create a partition type such as LVM or raid, parted (which
is used as the disk management backend) does not support setting this
partition type when creating the partition but instead by setting a flag
on the partition after it has been created. As it is not possible to
decide at which position in the partition table the new partition should
be created, parted will just choose the next available number. To be
able to set this flag on the partition, we need to know which partition
we just created, and suddenly the name of the volume is important, but
only if it has followed the rules that parted applied when finding the
next available slot. If the name of the volume is incorrect we will end
up with a volume created with incorrect type since we can't do 2
operation towards parted in a transaction manner (e.g. Volume name is
sdb2 but the newly created partition is sdb1).
I see two possible solutions on this problem:
1. We add volume name constraints in this case that makes sure that when
a volume is created by a user (by checking the pool and scan all ready
existing volumes in that pool), it has to create a name that is correct
according to parted's rules. In that case we can use the volume name to
find the partition just created and we can set the flag on the partition
in a safe way
2. we extend the libvirt_parthelper and uses the libparted instead to
create a partition, which then can be made in a more transaction like
manner. However, in this case we have to more or less add all the
support that parted has for creating a partition which is quite
extensive.
I put my vote on solution 1 but I like to know your opinion and also if
any one knows that the initial plans were.
/Henrik
15 years, 5 months
[libvirt] Extend virConfParser to allow parsing VMware VMX config files
by Matthias Bolte
Hi,
As part of the VMware ESX driver I need to parse VMware VMX config
files. This files have basically the same syntax as Xen config files,
but the key part of the key=value format is allowed to contain ':' and
'.'.
The attached patch adds a flag to the virConfParser to enabled a VMX
mode for the parser to allow ':' and '.' in the key, as suggested by
Daniel P. Berrange on IRC.
Regards
Matthias
15 years, 5 months
[libvirt] [PATCH] Cleanup when Storage Pool Create fails.
by Henrik Persson E
When libvirt fails to create a storage pool (e.g. a disk pool does not
have a partition table), the failed storage pool is not cleaned up
correctly and is not possible to re-create the pool again. This attached
patch addresses this problem.
/Henrik
15 years, 5 months
[libvirt] netbsd5.0
by Fabien Georget
Hi
I want to run netbsd 5.0 with kvm in virt-manager. It works with default
option but any network devices is recognized by the netbsd kernel.
To enable network with qemu-kvm, we had to disable the acpi and add other
options like -tdf, -localtime ... This is an an example who works :
http://ghantoos.org/2009/05/12/my-first-shot-of-netbsd/ (An explanation I found
is that the new scheduler in netbsd 5.0 cause some problems with
virtualization based on VT)
Currently, I have not found the way to do it with libvirt (and I don't think
it is possible with virt-manager).
It be very helpeful if these features can be add to libvirt.
Thanks
Fabien Georget
15 years, 5 months