提交 184fc07f 编写于 作者: P Philipp Hahn 提交者: Eric Blake

xen_xs: name xendConfigVersion magic numbers

libvirt supports 4 different versions of the user-land XenD daemon. When
queried the daemon just returns its generation number, which is hard to
match to the version of the Xen tools.

Replace the magic generation numbers by named enum definitions to
improve code readability.
Signed-off-by: NPhilipp Hahn <hahn@univention.de>
上级 be9fb5af
......@@ -100,7 +100,7 @@ index dfc6415..3642296 100644
+ /* If xendConfigVersion is 2, then we can only report _LIVE (and
+ * xm_internal reports _CONFIG). If it is 3, then _LIVE and
+ * _CONFIG are always in sync for a running system. */
+ if (domain->id < 0 && priv->xendConfigVersion < 3)
+ if (domain->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
+ return -2;
+ if (domain->id < 0 && (flags & VIR_DOMAIN_VCPU_LIVE)) {
+ virXendError(VIR_ERR_OPERATION_INVALID, "%s",
......
......@@ -110,7 +110,7 @@ index fe2ff86..66e8518 100644
+ * depends on xendConfigVersion. */
+ if (dom) {
+ priv = dom->conn->privateData;
+ if (priv->xendConfigVersion >= 3)
+ if (priv->xendConfigVersion >= XEND_CONFIG_VERSION_3_0_4)
+ flags |= VIR_DOMAIN_VCPU_CONFIG;
+ }
+ return xenUnifiedDomainSetVcpusFlags(dom, nvcpus, flags);
......@@ -163,14 +163,14 @@ index 3642296..55c2cc4 100644
+
+ priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
+
+ if ((domain->id < 0 && priv->xendConfigVersion < 3) ||
+ if ((domain->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) ||
+ (flags & VIR_DOMAIN_VCPU_MAXIMUM))
+ return -2;
+
+ /* With xendConfigVersion 2, only _LIVE is supported. With
+ * xendConfigVersion 3, only _LIVE|_CONFIG is supported for
+ * running domains, or _CONFIG for inactive domains. */
+ if (priv->xendConfigVersion < 3) {
+ if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
+ if (flags & VIR_DOMAIN_VCPU_CONFIG) {
+ virXendError(VIR_ERR_OPERATION_INVALID, "%s",
+ _("Xend version does not support modifying "
......
......@@ -122,7 +122,7 @@ index 55c2cc4..b90c331 100644
-
- priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
-
- if (domain->id < 0 && priv->xendConfigVersion < 3)
- if (domain->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
- return(-1);
-
- snprintf(buf, sizeof(buf), "%d", vcpus);
......
......@@ -354,7 +354,7 @@ xenUnifiedOpen (virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags)
/* XenD is active, so try the xm & xs drivers too, both requird to
* succeed if root, optional otherwise */
if (priv->xendConfigVersion <= 2) {
if (priv->xendConfigVersion <= XEND_CONFIG_VERSION_3_0_3) {
VIR_DEBUG("Trying XM sub-driver");
if (xenXMOpen(conn, auth, flags) == VIR_DRV_OPEN_SUCCESS) {
VIR_DEBUG("Activated XM sub-driver");
......@@ -1161,7 +1161,7 @@ xenUnifiedDomainSetVcpus (virDomainPtr dom, unsigned int nvcpus)
* depends on xendConfigVersion. */
if (dom) {
priv = dom->conn->privateData;
if (priv->xendConfigVersion >= 3)
if (priv->xendConfigVersion >= XEND_CONFIG_VERSION_3_0_4)
flags |= VIR_DOMAIN_VCPU_CONFIG;
}
return xenUnifiedDomainSetVcpusFlags(dom, nvcpus, flags);
......@@ -1239,7 +1239,7 @@ xenUnifiedDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
{
GET_PRIVATE(dom->conn);
if (dom->id == -1 && priv->xendConfigVersion < 3 ) {
if (dom->id == -1 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
if (priv->opened[XEN_UNIFIED_XM_OFFSET])
return xenXMDomainGetXMLDesc(dom, flags);
} else {
......@@ -1561,7 +1561,7 @@ xenUnifiedDomainAttachDevice (virDomainPtr dom, const char *xml)
* to make this API work
*/
if (priv->opened[XEN_UNIFIED_XEND_OFFSET] &&
priv->xendConfigVersion >= 3)
priv->xendConfigVersion >= XEND_CONFIG_VERSION_3_0_4)
flags |= VIR_DOMAIN_DEVICE_MODIFY_CONFIG;
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
......@@ -1600,7 +1600,7 @@ xenUnifiedDomainDetachDevice (virDomainPtr dom, const char *xml)
* to make this API work
*/
if (priv->opened[XEN_UNIFIED_XEND_OFFSET] &&
priv->xendConfigVersion >= 3)
priv->xendConfigVersion >= XEND_CONFIG_VERSION_3_0_4)
flags |= VIR_DOMAIN_DEVICE_MODIFY_CONFIG;
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
......@@ -1642,7 +1642,7 @@ xenUnifiedDomainGetAutostart (virDomainPtr dom, int *autostart)
{
GET_PRIVATE(dom->conn);
if (priv->xendConfigVersion < 3) {
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
if (priv->opened[XEN_UNIFIED_XM_OFFSET])
return xenXMDomainGetAutostart(dom, autostart);
} else {
......@@ -1659,7 +1659,7 @@ xenUnifiedDomainSetAutostart (virDomainPtr dom, int autostart)
{
GET_PRIVATE(dom->conn);
if (priv->xendConfigVersion < 3) {
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
if (priv->opened[XEN_UNIFIED_XM_OFFSET])
return xenXMDomainSetAutostart(dom, autostart);
} else {
......
......@@ -954,7 +954,7 @@ xend_detect_config_version(virConnectPtr conn) {
} else {
/* Xen prior to 3.0.3 did not have the xend_config_format
field, and is implicitly version 1. */
priv->xendConfigVersion = 1;
priv->xendConfigVersion = XEND_CONFIG_VERSION_3_0_2;
}
sexpr_free(root);
return (0);
......@@ -1224,7 +1224,7 @@ sexpr_to_domain(virConnectPtr conn, const struct sexpr *root)
/* New 3.0.4 XenD will not report a domid for inactive domains,
* so only error out for old XenD
*/
if (!tmp && priv->xendConfigVersion < 3)
if (!tmp && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
goto error;
if (tmp)
......@@ -1512,7 +1512,7 @@ xenDaemonDomainGetOSType(virDomainPtr domain)
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
if (domain->id < 0 && priv->xendConfigVersion < 3)
if (domain->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
return(NULL);
/* can we ask for a subset ? worth it ? */
......@@ -1652,7 +1652,7 @@ xenDaemonDomainGetMaxMemory(virDomainPtr domain)
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
if (domain->id < 0 && priv->xendConfigVersion < 3)
if (domain->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
return(-1);
/* can we ask for a subset ? worth it ? */
......@@ -1691,7 +1691,7 @@ xenDaemonDomainSetMaxMemory(virDomainPtr domain, unsigned long memory)
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
if (domain->id < 0 && priv->xendConfigVersion < 3)
if (domain->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
return(-1);
snprintf(buf, sizeof(buf), "%lu", VIR_DIV_UP(memory, 1024));
......@@ -1728,7 +1728,7 @@ xenDaemonDomainSetMemory(virDomainPtr domain, unsigned long memory)
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
if (domain->id < 0 && priv->xendConfigVersion < 3)
if (domain->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
return(-1);
snprintf(buf, sizeof(buf), "%lu", VIR_DIV_UP(memory, 1024));
......@@ -1808,7 +1808,7 @@ xenDaemonDomainGetXMLDesc(virDomainPtr domain, unsigned int flags,
}
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
if (domain->id < 0 && priv->xendConfigVersion < 3) {
if (domain->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
/* fall-through to the next driver to handle */
return(NULL);
}
......@@ -1852,7 +1852,7 @@ xenDaemonDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
if (domain->id < 0 && priv->xendConfigVersion < 3)
if (domain->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
return(-1);
root = sexpr_get(domain->conn, "/xend/domain/%s?detail=1", domain->name);
......@@ -1887,7 +1887,7 @@ xenDaemonDomainGetState(virDomainPtr domain,
virCheckFlags(0, -1);
if (domain->id < 0 && priv->xendConfigVersion < 3)
if (domain->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
return -1;
root = sexpr_get(domain->conn, "/xend/domain/%s?detail=1", domain->name);
......@@ -2186,14 +2186,14 @@ xenDaemonDomainSetVcpusFlags(virDomainPtr domain, unsigned int vcpus,
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
if ((domain->id < 0 && priv->xendConfigVersion < 3) ||
if ((domain->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) ||
(flags & VIR_DOMAIN_VCPU_MAXIMUM))
return -2;
/* With xendConfigVersion 2, only _LIVE is supported. With
* xendConfigVersion 3, only _LIVE|_CONFIG is supported for
* running domains, or _CONFIG for inactive domains. */
if (priv->xendConfigVersion < 3) {
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
if (flags & VIR_DOMAIN_VCPU_CONFIG) {
virXendError(VIR_ERR_OPERATION_INVALID, "%s",
_("Xend version does not support modifying "
......@@ -2267,7 +2267,7 @@ xenDaemonDomainPinVcpu(virDomainPtr domain, unsigned int vcpu,
}
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
if (priv->xendConfigVersion < 3) {
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
mapstr[0] = '[';
mapstr[1] = 0;
} else {
......@@ -2280,7 +2280,7 @@ xenDaemonDomainPinVcpu(virDomainPtr domain, unsigned int vcpu,
snprintf(buf, sizeof(buf), "%d,", (8 * i) + j);
strcat(mapstr, buf);
}
if (priv->xendConfigVersion < 3)
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
mapstr[strlen(mapstr) - 1] = ']';
else
mapstr[strlen(mapstr) - 1] = 0;
......@@ -2343,7 +2343,7 @@ xenDaemonDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags)
/* If xendConfigVersion is 2, then we can only report _LIVE (and
* xm_internal reports _CONFIG). If it is 3, then _LIVE and
* _CONFIG are always in sync for a running system. */
if (domain->id < 0 && priv->xendConfigVersion < 3)
if (domain->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
return -2;
if (domain->id < 0 && (flags & VIR_DOMAIN_VCPU_LIVE)) {
virXendError(VIR_ERR_OPERATION_INVALID, "%s",
......@@ -2477,7 +2477,7 @@ xenDaemonLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
xenUnifiedPrivatePtr priv = (xenUnifiedPrivatePtr) conn->privateData;
/* Old approach for xen <= 3.0.3 */
if (priv->xendConfigVersion < 3) {
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
char **names, **tmp;
unsigned char ident[VIR_UUID_BUFLEN];
names = xenDaemonListDomainsOld(conn);
......@@ -2648,7 +2648,7 @@ xenDaemonAttachDeviceFlags(virDomainPtr domain, const char *xml,
return -1;
}
/* If xendConfigVersion < 3 only live config can be changed */
if (priv->xendConfigVersion < 3) {
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
virXendError(VIR_ERR_OPERATION_INVALID, "%s",
_("Xend version does not support modifying "
"persistent config"));
......@@ -2656,7 +2656,7 @@ xenDaemonAttachDeviceFlags(virDomainPtr domain, const char *xml,
}
} else {
/* Only live config can be changed if xendConfigVersion < 3 */
if (priv->xendConfigVersion < 3 &&
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4 &&
(flags != VIR_DOMAIN_DEVICE_MODIFY_CURRENT &&
flags != VIR_DOMAIN_DEVICE_MODIFY_LIVE)) {
virXendError(VIR_ERR_OPERATION_INVALID, "%s",
......@@ -2667,7 +2667,7 @@ xenDaemonAttachDeviceFlags(virDomainPtr domain, const char *xml,
/* Xen only supports modifying both live and persistent config if
* xendConfigVersion >= 3
*/
if (priv->xendConfigVersion >= 3 &&
if (priv->xendConfigVersion >= XEND_CONFIG_VERSION_3_0_4 &&
(flags != (VIR_DOMAIN_DEVICE_MODIFY_LIVE |
VIR_DOMAIN_DEVICE_MODIFY_CONFIG))) {
virXendError(VIR_ERR_OPERATION_INVALID, "%s",
......@@ -2816,7 +2816,7 @@ xenDaemonUpdateDeviceFlags(virDomainPtr domain, const char *xml,
return -1;
}
/* If xendConfigVersion < 3 only live config can be changed */
if (priv->xendConfigVersion < 3) {
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
virXendError(VIR_ERR_OPERATION_INVALID, "%s",
_("Xend version does not support modifying "
"persistent config"));
......@@ -2824,7 +2824,7 @@ xenDaemonUpdateDeviceFlags(virDomainPtr domain, const char *xml,
}
} else {
/* Only live config can be changed if xendConfigVersion < 3 */
if (priv->xendConfigVersion < 3 &&
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4 &&
(flags != VIR_DOMAIN_DEVICE_MODIFY_CURRENT &&
flags != VIR_DOMAIN_DEVICE_MODIFY_LIVE)) {
virXendError(VIR_ERR_OPERATION_INVALID, "%s",
......@@ -2835,7 +2835,7 @@ xenDaemonUpdateDeviceFlags(virDomainPtr domain, const char *xml,
/* Xen only supports modifying both live and persistent config if
* xendConfigVersion >= 3
*/
if (priv->xendConfigVersion >= 3 &&
if (priv->xendConfigVersion >= XEND_CONFIG_VERSION_3_0_4 &&
(flags != (VIR_DOMAIN_DEVICE_MODIFY_LIVE |
VIR_DOMAIN_DEVICE_MODIFY_CONFIG))) {
virXendError(VIR_ERR_OPERATION_INVALID, "%s",
......@@ -2929,7 +2929,7 @@ xenDaemonDetachDeviceFlags(virDomainPtr domain, const char *xml,
return -1;
}
/* If xendConfigVersion < 3 only live config can be changed */
if (priv->xendConfigVersion < 3) {
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
virXendError(VIR_ERR_OPERATION_INVALID, "%s",
_("Xend version does not support modifying "
"persistent config"));
......@@ -2937,7 +2937,7 @@ xenDaemonDetachDeviceFlags(virDomainPtr domain, const char *xml,
}
} else {
/* Only live config can be changed if xendConfigVersion < 3 */
if (priv->xendConfigVersion < 3 &&
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4 &&
(flags != VIR_DOMAIN_DEVICE_MODIFY_CURRENT &&
flags != VIR_DOMAIN_DEVICE_MODIFY_LIVE)) {
virXendError(VIR_ERR_OPERATION_INVALID, "%s",
......@@ -2948,7 +2948,7 @@ xenDaemonDetachDeviceFlags(virDomainPtr domain, const char *xml,
/* Xen only supports modifying both live and persistent config if
* xendConfigVersion >= 3
*/
if (priv->xendConfigVersion >= 3 &&
if (priv->xendConfigVersion >= XEND_CONFIG_VERSION_3_0_4 &&
(flags != (VIR_DOMAIN_DEVICE_MODIFY_LIVE |
VIR_DOMAIN_DEVICE_MODIFY_CONFIG))) {
virXendError(VIR_ERR_OPERATION_INVALID, "%s",
......@@ -3016,7 +3016,7 @@ xenDaemonDomainGetAutostart(virDomainPtr domain,
* config files used by old Xen) will handle this.
*/
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
if (priv->xendConfigVersion < 3)
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
return(-1);
root = sexpr_get(domain->conn, "/xend/domain/%s?detail=1", domain->name);
......@@ -3056,7 +3056,7 @@ xenDaemonDomainSetAutostart(virDomainPtr domain,
* config files used by old Xen) will handle this.
*/
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
if (priv->xendConfigVersion < 3)
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
return(-1);
root = sexpr_get(domain->conn, "/xend/domain/%s?detail=1", domain->name);
......@@ -3318,7 +3318,7 @@ virDomainPtr xenDaemonDomainDefineXML(virConnectPtr conn, const char *xmlDesc) {
priv = (xenUnifiedPrivatePtr) conn->privateData;
if (priv->xendConfigVersion < 3)
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
return(NULL);
if (!(def = virDomainDefParseString(priv->caps, xmlDesc,
......@@ -3367,7 +3367,7 @@ int xenDaemonDomainCreate(virDomainPtr domain)
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
if (priv->xendConfigVersion < 3)
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
return(-1);
ret = xend_op(domain->conn, domain->name, "op", "start", NULL);
......@@ -3394,7 +3394,7 @@ int xenDaemonDomainUndefine(virDomainPtr domain)
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
if (priv->xendConfigVersion < 3)
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
return(-1);
return xend_op(domain->conn, domain->name, "op", "delete", NULL);
......@@ -3419,7 +3419,7 @@ xenDaemonNumOfDefinedDomains(virConnectPtr conn)
/* xm_internal.c (the support for defined domains from /etc/xen
* config files used by old Xen) will handle this.
*/
if (priv->xendConfigVersion < 3)
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
return(-1);
root = sexpr_get(conn, "/xend/domain?state=halted");
......@@ -3447,7 +3447,7 @@ xenDaemonListDefinedDomains(virConnectPtr conn, char **const names, int maxnames
struct sexpr *_for_i, *node;
xenUnifiedPrivatePtr priv = (xenUnifiedPrivatePtr) conn->privateData;
if (priv->xendConfigVersion < 3)
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
return(-1);
if ((names == NULL) || (maxnames < 0))
......@@ -3513,7 +3513,7 @@ xenDaemonGetSchedulerType(virDomainPtr domain, int *nparams)
/* Support only xendConfigVersion >=4 */
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
if (priv->xendConfigVersion < 4) {
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_1_0) {
virXendError(VIR_ERR_OPERATION_INVALID,
"%s", _("unsupported in xendConfigVersion < 4"));
return NULL;
......@@ -3586,7 +3586,7 @@ xenDaemonGetSchedulerParameters(virDomainPtr domain,
/* Support only xendConfigVersion >=4 */
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
if (priv->xendConfigVersion < 4) {
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_1_0) {
virXendError(VIR_ERR_OPERATION_INVALID,
"%s", _("unsupported in xendConfigVersion < 4"));
return (-1);
......@@ -3694,7 +3694,7 @@ xenDaemonSetSchedulerParameters(virDomainPtr domain,
/* Support only xendConfigVersion >=4 and active domains */
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
if (priv->xendConfigVersion < 4) {
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_1_0) {
virXendError(VIR_ERR_OPERATION_INVALID,
"%s", _("unsupported in xendConfigVersion < 4"));
return (-1);
......@@ -3802,7 +3802,7 @@ xenDaemonDomainBlockPeek (virDomainPtr domain, const char *path,
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
if (domain->id < 0 && priv->xendConfigVersion < 3)
if (domain->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
return -2; /* Decline, allow XM to handle it. */
/* Security check: The path must correspond to a block device. */
......
......@@ -55,7 +55,7 @@ int xenGetDomIdFromSxpr(const struct sexpr *root, int xendConfigVersion)
{
int id = -1;
const char * tmp = sexpr_node(root, "domain/domid");
if (tmp == NULL && xendConfigVersion < 3) { /* Old XenD, domid was mandatory */
if (tmp == NULL && xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) { /* domid was mandatory */
XENXS_ERROR(VIR_ERR_INTERNAL_ERROR,
"%s", _("domain information incomplete, missing id"));
} else {
......@@ -468,7 +468,7 @@ xenParseSxprDisks(virDomainDefPtr def,
disk->device = VIR_DOMAIN_DISK_DEVICE_DISK;
/* New style disk config from Xen >= 3.0.3 */
if (xendConfigVersion > 1) {
if (xendConfigVersion >= XEND_CONFIG_VERSION_3_0_3) {
offset = strrchr(dst, ':');
if (offset) {
if (STREQ (offset, ":cdrom")) {
......@@ -814,7 +814,7 @@ xenParseSxprGraphicsOld(virDomainDefPtr def,
* present yet. Subsquent dumps of the XML will eventually
* find the port in XenStore once VNC server has started
*/
if (port == -1 && xendConfigVersion < 2)
if (port == -1 && xendConfigVersion < XEND_CONFIG_VERSION_3_0_3)
port = 5900 + def->id;
if ((unused && STREQ(unused, "1")) || port == -1)
......@@ -1132,7 +1132,7 @@ xenParseSxpr(const struct sexpr *root,
goto no_memory;
tmp = sexpr_node(root, "domain/domid");
if (tmp == NULL && xendConfigVersion < 3) { /* Old XenD, domid was mandatory */
if (tmp == NULL && xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) { /* domid was mandatory */
XENXS_ERROR(VIR_ERR_INTERNAL_ERROR,
"%s", _("domain information incomplete, missing id"));
goto error;
......@@ -1318,7 +1318,7 @@ xenParseSxpr(const struct sexpr *root,
/* Old style cdrom config from Xen <= 3.0.2 */
if (hvm &&
xendConfigVersion == 1) {
xendConfigVersion == XEND_CONFIG_VERSION_3_0_2) {
tmp = sexpr_node(root, "domain/image/hvm/cdrom");
if ((tmp != NULL) && (tmp[0] != 0)) {
virDomainDiskDefPtr disk;
......@@ -1617,7 +1617,7 @@ xenFormatSxprGraphicsOld(virDomainGraphicsDefPtr def,
virBufferAsprintf(buf, "(xauthority '%s')", def->data.sdl.xauth);
} else if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
virBufferAddLit(buf, "(vnc 1)");
if (xendConfigVersion >= 2) {
if (xendConfigVersion >= XEND_CONFIG_VERSION_3_0_3) {
if (def->data.vnc.autoport) {
virBufferAddLit(buf, "(vncunused 1)");
} else {
......@@ -1762,7 +1762,7 @@ xenFormatSxprDisk(virDomainDiskDefPtr def,
/* Xend <= 3.0.2 doesn't include cdrom config here */
if (hvm &&
def->device == VIR_DOMAIN_DISK_DEVICE_CDROM &&
xendConfigVersion == 1) {
xendConfigVersion == XEND_CONFIG_VERSION_3_0_2) {
if (isAttach) {
XENXS_ERROR(VIR_ERR_INVALID_ARG,
_("Cannot directly attach CDROM %s"), def->src);
......@@ -1787,7 +1787,7 @@ xenFormatSxprDisk(virDomainDiskDefPtr def,
if (hvm) {
/* Xend <= 3.0.2 wants a ioemu: prefix on devices for HVM */
if (xendConfigVersion == 1) {
if (xendConfigVersion == XEND_CONFIG_VERSION_3_0_2) {
virBufferEscapeSexpr(buf, "(dev 'ioemu:%s')", def->dst);
} else {
/* But newer does not */
......@@ -2338,7 +2338,7 @@ xenFormatSxpr(virConnectPtr conn,
switch (def->disks[i]->device) {
case VIR_DOMAIN_DISK_DEVICE_CDROM:
/* Only xend <= 3.0.2 wants cdrom config here */
if (xendConfigVersion != 1)
if (xendConfigVersion != XEND_CONFIG_VERSION_3_0_2)
break;
if (!STREQ(def->disks[i]->dst, "hdc") ||
def->disks[i]->src == NULL)
......@@ -2437,7 +2437,7 @@ xenFormatSxpr(virConnectPtr conn,
}
/* get the device emulation model */
if (def->emulator && (hvm || xendConfigVersion >= 3))
if (def->emulator && (hvm || xendConfigVersion >= XEND_CONFIG_VERSION_3_0_4))
virBufferEscapeSexpr(&buf, "(device_model '%s')", def->emulator);
/* look for HPET in order to override the hypervisor/xend default */
......@@ -2452,7 +2452,7 @@ xenFormatSxpr(virConnectPtr conn,
/* PV graphics for xen <= 3.0.4, or HVM graphics for xen <= 3.1.0 */
if ((!hvm && xendConfigVersion < XEND_CONFIG_MIN_VERS_PVFB_NEWCONF) ||
(hvm && xendConfigVersion < 4)) {
(hvm && xendConfigVersion < XEND_CONFIG_VERSION_3_1_0)) {
if ((def->ngraphics == 1) &&
xenFormatSxprGraphicsOld(def->graphics[0],
&buf, xendConfigVersion) < 0)
......@@ -2484,7 +2484,7 @@ xenFormatSxpr(virConnectPtr conn,
/* New style PV graphics config xen >= 3.0.4,
* or HVM graphics config xen >= 3.0.5 */
if ((xendConfigVersion >= XEND_CONFIG_MIN_VERS_PVFB_NEWCONF && !hvm) ||
(xendConfigVersion >= 4 && hvm)) {
(xendConfigVersion >= XEND_CONFIG_VERSION_3_1_0 && hvm)) {
if ((def->ngraphics == 1) &&
xenFormatSxprGraphicsNew(def->graphics[0], &buf) < 0)
goto error;
......
/*
* xen_sxpr.h: Xen SEXPR parsing functions
*
* Copyright (C) 2006-2008, 2010, 2012 Red Hat, Inc.
* Copyright (C) 2011 Univention GmbH
* Copyright (C) 2006-2008, 2010 Red Hat, Inc.
* Copyright (C) 2005,2006
*
* This library is free software; you can redistribute it and/or
......@@ -32,6 +32,13 @@
# include "domain_conf.h"
# include "sexpr.h"
typedef enum {
XEND_CONFIG_VERSION_3_0_2 = 1,
XEND_CONFIG_VERSION_3_0_3 = 2,
XEND_CONFIG_VERSION_3_0_4 = 3,
XEND_CONFIG_VERSION_3_1_0 = 4,
} xenConfigVersionEnum;
/* helper functions to get the dom id from a sexpr */
int xenGetDomIdFromSxprString(const char *sexpr, int xendConfigVersion);
int xenGetDomIdFromSxpr(const struct sexpr *root, int xendConfigVersion);
......
......@@ -570,7 +570,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
}
}
if (hvm && xendConfigVersion == 1) {
if (hvm && xendConfigVersion == XEND_CONFIG_VERSION_3_0_2) {
if (xenXMConfigGetString(conf, "cdrom", &str, NULL) < 0)
goto cleanup;
if (str) {
......@@ -858,7 +858,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
}
/* HVM guests, or old PV guests use this config format */
if (hvm || xendConfigVersion < 3) {
if (hvm || xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
if (xenXMConfigGetBool(conf, "vnc", &val, 0) < 0)
goto cleanup;
......@@ -1169,7 +1169,7 @@ static int xenFormatXMDisk(virConfValuePtr list,
virBufferAdd(&buf, disk->src, -1);
}
virBufferAddLit(&buf, ",");
if (hvm && xendConfigVersion == 1)
if (hvm && xendConfigVersion == XEND_CONFIG_VERSION_3_0_2)
virBufferAddLit(&buf, "ioemu:");
virBufferAdd(&buf, disk->dst, -1);
......@@ -1545,7 +1545,7 @@ virConfPtr xenFormatXM(virConnectPtr conn,
(1 << VIR_DOMAIN_FEATURE_APIC)) ? 1 : 0) < 0)
goto no_memory;
if (xendConfigVersion >= 3) {
if (xendConfigVersion >= XEND_CONFIG_VERSION_3_0_4) {
if (xenXMConfigSetInt(conf, "hap",
(def->features &
(1 << VIR_DOMAIN_FEATURE_HAP)) ? 1 : 0) < 0)
......@@ -1584,7 +1584,7 @@ virConfPtr xenFormatXM(virConnectPtr conn,
break;
}
if (xendConfigVersion == 1) {
if (xendConfigVersion == XEND_CONFIG_VERSION_3_0_2) {
for (i = 0 ; i < def->ndisks ; i++) {
if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_CDROM &&
def->disks[i]->dst &&
......@@ -1665,7 +1665,7 @@ virConfPtr xenFormatXM(virConnectPtr conn,
}
if (def->ngraphics == 1) {
if (xendConfigVersion < (hvm ? 4 : XEND_CONFIG_MIN_VERS_PVFB_NEWCONF)) {
if (xendConfigVersion < (hvm ? XEND_CONFIG_VERSION_3_1_0 : XEND_CONFIG_MIN_VERS_PVFB_NEWCONF)) {
if (def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SDL) {
if (xenXMConfigSetInt(conf, "sdl", 1) < 0)
goto no_memory;
......@@ -1772,7 +1772,7 @@ virConfPtr xenFormatXM(virConnectPtr conn,
diskVal->list = NULL;
for (i = 0 ; i < def->ndisks ; i++) {
if (xendConfigVersion == 1 &&
if (xendConfigVersion == XEND_CONFIG_VERSION_3_0_2 &&
def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_CDROM &&
def->disks[i]->dst &&
STREQ(def->disks[i]->dst, "hdc")) {
......
......@@ -29,6 +29,7 @@
# include <stdint.h>
# include <xen/xen.h>
# include "xen_sxpr.h"
/* xen-unstable changeset 19788 removed MAX_VIRT_CPUS from public
* headers. Its semantic was retained with XEN_LEGACY_MAX_VCPUS.
......@@ -40,10 +41,10 @@
# ifdef WITH_RHEL5_API
# define XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU 0
# define XEND_CONFIG_MIN_VERS_PVFB_NEWCONF 2
# define XEND_CONFIG_MIN_VERS_PVFB_NEWCONF XEND_CONFIG_VERSION_3_0_3
# else
# define XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU 3
# define XEND_CONFIG_MIN_VERS_PVFB_NEWCONF 3
# define XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU XEND_CONFIG_VERSION_3_0_4
# define XEND_CONFIG_MIN_VERS_PVFB_NEWCONF XEND_CONFIG_VERSION_3_0_4
# endif
# define MIN_XEN_GUEST_SIZE 64 /* 64 megabytes */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册