mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
util: storage: Drop pointless 'enabled' form PR definition
Everything can be disabled by not using the parent element. There's no need to store this explicitly. Additionally it does not add any value since any configuration is dropped if enabled='no' is configured. Drop the attribute and adjust the code accordingly. Signed-off-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
1efda36765
commit
e72b3f0bbe
@ -2583,7 +2583,7 @@
|
|||||||
<disk type='block' device='lun'>
|
<disk type='block' device='lun'>
|
||||||
<driver name='qemu' type='raw'/>
|
<driver name='qemu' type='raw'/>
|
||||||
<source dev='/dev/sda'>
|
<source dev='/dev/sda'>
|
||||||
<reservations enabled='yes' managed='no'>
|
<reservations managed='no'>
|
||||||
<source type='unix' path='/path/to/qemu-pr-helper' mode='client'/>
|
<source type='unix' path='/path/to/qemu-pr-helper' mode='client'/>
|
||||||
</reservations>
|
</reservations>
|
||||||
<target dev='sda' bus='scsi'/>
|
<target dev='sda' bus='scsi'/>
|
||||||
@ -2952,19 +2952,19 @@
|
|||||||
<dd><span class="since">Since libvirt 4.4.0</span>, the
|
<dd><span class="since">Since libvirt 4.4.0</span>, the
|
||||||
<code>reservations</code> can be a sub-element of the
|
<code>reservations</code> can be a sub-element of the
|
||||||
<code>source</code> element for storage sources (QEMU driver only).
|
<code>source</code> element for storage sources (QEMU driver only).
|
||||||
If present (and enabled) it enables persistent reservations for SCSI
|
If present it enables persistent reservations for SCSI
|
||||||
based disks. The element has one mandatory attribute
|
based disks. The element has one mandatory attribute
|
||||||
<code>enabled</code> with accepted values <code>yes</code> and
|
<code>managed</code> with accepted values <code>yes</code> and
|
||||||
<code>no</code>. If the feature is enabled, then there's another
|
<code>no</code>. If <code>managed</code> is enabled libvirt prepares
|
||||||
mandatory attribute <code>managed</code> (accepted values are the
|
and manages any resources needed. When the persistent reservations
|
||||||
same as for <code>enabled</code>) that enables or disables libvirt
|
are unmanaged, then the hypervisor acts as a client and the path to
|
||||||
spawning a helper process. When the PR is unmanaged, then hypervisor
|
the server socket must be provided in the child element
|
||||||
acts as a client and path to server socket must be provided in child
|
<code>source</code>, which currently accepts only the following
|
||||||
element <code>source</code>, which currently accepts only the
|
attributes:
|
||||||
following attributes: <code>type</code> with one value
|
<code>type</code> with one value <code>unix</code>,
|
||||||
<code>unix</code>, <code>path</code> with path the socket, and
|
<code>path</code> path to the socket, and
|
||||||
finally <code>mode</code> which accepts one value
|
finally <code>mode</code> which accepts one value
|
||||||
<code>client</code> and specifies the role of hypervisor.
|
<code>client</code> specifying the role of hypervisor.
|
||||||
It's recommended to allow libvirt manage the persistent
|
It's recommended to allow libvirt manage the persistent
|
||||||
reservations.
|
reservations.
|
||||||
</dd>
|
</dd>
|
||||||
|
@ -75,9 +75,6 @@
|
|||||||
|
|
||||||
<define name='reservations'>
|
<define name='reservations'>
|
||||||
<element name='reservations'>
|
<element name='reservations'>
|
||||||
<attribute name='enabled'>
|
|
||||||
<ref name='virYesNo'/>
|
|
||||||
</attribute>
|
|
||||||
<optional>
|
<optional>
|
||||||
<attribute name='managed'>
|
<attribute name='managed'>
|
||||||
<ref name='virYesNo'/>
|
<ref name='virYesNo'/>
|
||||||
|
@ -1906,8 +1906,8 @@ virStoragePRDefFree(virStoragePRDefPtr prd)
|
|||||||
virStoragePRDefPtr
|
virStoragePRDefPtr
|
||||||
virStoragePRDefParseXML(xmlXPathContextPtr ctxt)
|
virStoragePRDefParseXML(xmlXPathContextPtr ctxt)
|
||||||
{
|
{
|
||||||
virStoragePRDefPtr prd, ret = NULL;
|
virStoragePRDefPtr prd;
|
||||||
char *enabled = NULL;
|
virStoragePRDefPtr ret = NULL;
|
||||||
char *managed = NULL;
|
char *managed = NULL;
|
||||||
char *type = NULL;
|
char *type = NULL;
|
||||||
char *path = NULL;
|
char *path = NULL;
|
||||||
@ -1916,81 +1916,65 @@ virStoragePRDefParseXML(xmlXPathContextPtr ctxt)
|
|||||||
if (VIR_ALLOC(prd) < 0)
|
if (VIR_ALLOC(prd) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!(enabled = virXPathString("string(./@enabled)", ctxt))) {
|
if (!(managed = virXPathString("string(./@managed)", ctxt))) {
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
_("missing @enabled attribute for <reservations/>"));
|
_("missing @managed attribute for <reservations/>"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((prd->enabled = virTristateBoolTypeFromString(enabled)) <= 0) {
|
if ((prd->managed = virTristateBoolTypeFromString(managed)) <= 0) {
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
_("invalid value for 'enabled': %s"), enabled);
|
_("invalid value for 'managed': %s"), managed);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prd->enabled == VIR_TRISTATE_BOOL_YES) {
|
if (prd->managed == VIR_TRISTATE_BOOL_NO) {
|
||||||
if (!(managed = virXPathString("string(./@managed)", ctxt))) {
|
type = virXPathString("string(./source[1]/@type)", ctxt);
|
||||||
|
path = virXPathString("string(./source[1]/@path)", ctxt);
|
||||||
|
mode = virXPathString("string(./source[1]/@mode)", ctxt);
|
||||||
|
|
||||||
|
if (!type) {
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
_("missing @managed attribute for <reservations/>"));
|
_("missing connection type for <reservations/>"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((prd->managed = virTristateBoolTypeFromString(managed)) <= 0) {
|
if (!path) {
|
||||||
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
|
_("missing path for <reservations/>"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mode) {
|
||||||
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
|
_("missing connection mode for <reservations/>"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (STRNEQ(type, "unix")) {
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
_("invalid value for 'managed': %s"), managed);
|
_("unsupported connection type for <reservations/>: %s"),
|
||||||
|
type);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prd->managed == VIR_TRISTATE_BOOL_NO) {
|
if (STRNEQ(mode, "client")) {
|
||||||
type = virXPathString("string(./source[1]/@type)", ctxt);
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
path = virXPathString("string(./source[1]/@path)", ctxt);
|
_("unsupported connection mode for <reservations/>: %s"),
|
||||||
mode = virXPathString("string(./source[1]/@mode)", ctxt);
|
mode);
|
||||||
|
goto cleanup;
|
||||||
if (!type) {
|
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
||||||
_("missing connection type for <reservations/>"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!path) {
|
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
||||||
_("missing path for <reservations/>"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!mode) {
|
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
||||||
_("missing connection mode for <reservations/>"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (STRNEQ(type, "unix")) {
|
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
|
||||||
_("unsupported connection type for <reservations/>: %s"),
|
|
||||||
type);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (STRNEQ(mode, "client")) {
|
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
|
||||||
_("unsupported connection mode for <reservations/>: %s"),
|
|
||||||
mode);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
VIR_STEAL_PTR(prd->path, path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VIR_STEAL_PTR(prd->path, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = prd;
|
VIR_STEAL_PTR(ret, prd);
|
||||||
prd = NULL;
|
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(mode);
|
VIR_FREE(mode);
|
||||||
VIR_FREE(path);
|
VIR_FREE(path);
|
||||||
VIR_FREE(type);
|
VIR_FREE(type);
|
||||||
VIR_FREE(managed);
|
VIR_FREE(managed);
|
||||||
VIR_FREE(enabled);
|
|
||||||
virStoragePRDefFree(prd);
|
virStoragePRDefFree(prd);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -2000,22 +1984,16 @@ void
|
|||||||
virStoragePRDefFormat(virBufferPtr buf,
|
virStoragePRDefFormat(virBufferPtr buf,
|
||||||
virStoragePRDefPtr prd)
|
virStoragePRDefPtr prd)
|
||||||
{
|
{
|
||||||
virBufferAsprintf(buf, "<reservations enabled='%s'",
|
virBufferAsprintf(buf, "<reservations managed='%s'",
|
||||||
virTristateBoolTypeToString(prd->enabled));
|
virTristateBoolTypeToString(prd->managed));
|
||||||
if (prd->enabled == VIR_TRISTATE_BOOL_YES) {
|
if (prd->managed == VIR_TRISTATE_BOOL_NO) {
|
||||||
virBufferAsprintf(buf, " managed='%s'",
|
virBufferAddLit(buf, ">\n");
|
||||||
virTristateBoolTypeToString(prd->managed));
|
virBufferAdjustIndent(buf, 2);
|
||||||
if (prd->managed == VIR_TRISTATE_BOOL_NO) {
|
virBufferAddLit(buf, "<source type='unix'");
|
||||||
virBufferAddLit(buf, ">\n");
|
virBufferEscapeString(buf, " path='%s'", prd->path);
|
||||||
virBufferAdjustIndent(buf, 2);
|
virBufferAddLit(buf, " mode='client'/>\n");
|
||||||
virBufferAddLit(buf, "<source type='unix'");
|
virBufferAdjustIndent(buf, -2);
|
||||||
virBufferEscapeString(buf, " path='%s'", prd->path);
|
virBufferAddLit(buf, "</reservations>\n");
|
||||||
virBufferAddLit(buf, " mode='client'/>\n");
|
|
||||||
virBufferAdjustIndent(buf, -2);
|
|
||||||
virBufferAddLit(buf, "</reservations>\n");
|
|
||||||
} else {
|
|
||||||
virBufferAddLit(buf, "/>\n");
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
virBufferAddLit(buf, "/>\n");
|
virBufferAddLit(buf, "/>\n");
|
||||||
}
|
}
|
||||||
@ -2032,8 +2010,7 @@ virStoragePRDefIsEqual(virStoragePRDefPtr a,
|
|||||||
if (!a || !b)
|
if (!a || !b)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (a->enabled != b->enabled ||
|
if (a->managed != b->managed ||
|
||||||
a->managed != b->managed ||
|
|
||||||
STRNEQ_NULLABLE(a->path, b->path))
|
STRNEQ_NULLABLE(a->path, b->path))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -2044,7 +2021,7 @@ virStoragePRDefIsEqual(virStoragePRDefPtr a,
|
|||||||
bool
|
bool
|
||||||
virStoragePRDefIsEnabled(virStoragePRDefPtr prd)
|
virStoragePRDefIsEnabled(virStoragePRDefPtr prd)
|
||||||
{
|
{
|
||||||
return prd && prd->enabled == VIR_TRISTATE_BOOL_YES;
|
return !!prd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -219,7 +219,6 @@ struct _virStorageAuthDef {
|
|||||||
typedef struct _virStoragePRDef virStoragePRDef;
|
typedef struct _virStoragePRDef virStoragePRDef;
|
||||||
typedef virStoragePRDef *virStoragePRDefPtr;
|
typedef virStoragePRDef *virStoragePRDefPtr;
|
||||||
struct _virStoragePRDef {
|
struct _virStoragePRDef {
|
||||||
int enabled; /* enum virTristateBool */
|
|
||||||
int managed; /* enum virTristateBool */
|
int managed; /* enum virTristateBool */
|
||||||
char *path;
|
char *path;
|
||||||
};
|
};
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
<disk type='block' device='lun'>
|
<disk type='block' device='lun'>
|
||||||
<driver name='qemu' type='raw'/>
|
<driver name='qemu' type='raw'/>
|
||||||
<source dev='/dev/HostVG/QEMUGuest1'>
|
<source dev='/dev/HostVG/QEMUGuest1'>
|
||||||
<reservations enabled='yes' managed='yes'/>
|
<reservations managed='yes'/>
|
||||||
</source>
|
</source>
|
||||||
<target dev='sda' bus='scsi'/>
|
<target dev='sda' bus='scsi'/>
|
||||||
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
|
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
|
||||||
@ -25,7 +25,7 @@
|
|||||||
<disk type='block' device='lun'>
|
<disk type='block' device='lun'>
|
||||||
<driver name='qemu' type='raw'/>
|
<driver name='qemu' type='raw'/>
|
||||||
<source dev='/dev/HostVG/QEMUGuest2'>
|
<source dev='/dev/HostVG/QEMUGuest2'>
|
||||||
<reservations enabled='yes' managed='no'>
|
<reservations managed='no'>
|
||||||
<source type='unix' path='/path/to/qemu-pr-helper.sock' mode='client'/>
|
<source type='unix' path='/path/to/qemu-pr-helper.sock' mode='client'/>
|
||||||
</reservations>
|
</reservations>
|
||||||
</source>
|
</source>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user