Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

bfebs-xen from dmitrii

  • Loading branch information...
commit b3c60c858bc6ba70a524629bd7b10298654dd12b 1 parent 2eba417
Daniel Nurmi authored
Showing with 71 additions and 18 deletions.
  1. +8 −1 node/xml.c
  2. +28 −3 storage/vbr.c
  3. +25 −13 tools/libvirt.xsl
  4. +10 −1 util/data.h
View
9 node/xml.c
@@ -182,6 +182,13 @@ int gen_instance_xml (const ncInstance * instance)
_ATTRIBUTE(hypervisor, "bitness", bitness);
}
+ { // backing specification (TODO: maybe expand this with device maps or whatnot?)
+ xmlNodePtr backing = xmlNewChild (instanceNode, NULL, BAD_CAST "backing", NULL);
+ xmlNodePtr root = xmlNewChild (backing, NULL, BAD_CAST "root", NULL);
+ assert (instance->params.root);
+ _ATTRIBUTE(root, "type", ncResourceTypeName[instance->params.root->type]);
+ }
+
_ELEMENT(instanceNode, "name", instance->instanceId);
_ELEMENT(instanceNode, "uuid", instance->uuid);
_ELEMENT(instanceNode, "reservation", instance->reservationId);
@@ -240,7 +247,7 @@ int gen_instance_xml (const ncInstance * instance)
if (!strcmp ("none", vbr->guestDeviceName))
continue;
// for Linux instances on Xen, partitions can be used directly, so disks can be skipped
- if (strstr (instance->platform, "linux") && strstr (instance->hypervisorType, "xen")) {
+ if (strstr (instance->platform, "linux") && strstr (instance->hypervisorType, "xen") && (vbr->type == NC_RESOURCE_IMAGE)) {
if (vbr->partitionNumber == 0) {
continue;
}
View
31 storage/vbr.c
@@ -163,7 +163,7 @@ parse_rec ( // parses the VBR as supplied by a client or user, checks values, an
if (strstr (vbr->typeName, "machine") == vbr->typeName) {
vbr->type = NC_RESOURCE_IMAGE;
if (vm)
- vm->image = vbr;
+ vm->root = vbr;
} else if (strstr (vbr->typeName, "kernel") == vbr->typeName) {
vbr->type = NC_RESOURCE_KERNEL;
if (vm)
@@ -353,7 +353,7 @@ vbr_parse ( // parses and verifies all VBR entries in the virtual machine defini
virtualMachine * vm, // vm definition containing VBR records
ncMetadata * meta) // OPTIONAL parameter for translating, e.g., walrus:// URI into http:// URI
{
- unsigned char partitions [BUS_TYPES_TOTAL][EUCA_MAX_DISKS][EUCA_MAX_PARTITIONS]; // for validating partitions
+ virtualBootRecord * partitions [BUS_TYPES_TOTAL][EUCA_MAX_DISKS][EUCA_MAX_PARTITIONS]; // for validating partitions
bzero (partitions, sizeof (partitions));
for (int i=0, j=0; i<EUCA_MAX_VBRS && i<vm->virtualBootRecordLen; i++) {
virtualBootRecord * vbr = &(vm->virtualBootRecord[i]);
@@ -362,7 +362,18 @@ vbr_parse ( // parses and verifies all VBR entries in the virtual machine defini
return ERROR;
if (vbr->type!=NC_RESOURCE_KERNEL && vbr->type!=NC_RESOURCE_RAMDISK)
- partitions [vbr->guestDeviceBus][vbr->diskNumber][vbr->partitionNumber] = 1;
+ partitions [vbr->guestDeviceBus][vbr->diskNumber][vbr->partitionNumber] = vbr;
+
+ if (vm->root==NULL) { // we have not identified the EMI yet
+ if (vbr->type==NC_RESOURCE_IMAGE) {
+ vm->root=vbr;
+ }
+ } else {
+ if (vbr->type==NC_RESOURCE_IMAGE) {
+ logprintfl (EUCAERROR, "Error: more than one EMI specified in the boot record\n");
+ return ERROR;
+ }
+ }
}
// ensure that partitions are contiguous and that partitions and disks are not mixed
@@ -382,10 +393,24 @@ vbr_parse ( // parses and verifies all VBR entries in the virtual machine defini
return ERROR;
}
}
+ if (vm->root==NULL) { // root partition or disk have not been found yet (no NC_RESOURCE_IMAGE)
+ virtualBootRecord * vbr;
+ if (has_partitions)
+ vbr = partitions [i][j][1];
+ else
+ vbr = partitions [i][j][0];
+ if (vbr && (vbr->type == NC_RESOURCE_EBS))
+ vm->root = vbr;
+ }
}
}
}
+ if (vm->root==NULL) {
+ logprintfl (EUCAERROR, "Error: no root partition or disk have been found\n");
+ return ERROR;
+ }
+
return OK;
}
View
38 tools/libvirt.xsl
@@ -27,8 +27,8 @@ that describes a Eucalyptus instance to be launched.
<description>Eucalyptus instance <xsl:value-of select="/instance/name"/></description>
<os>
<xsl:choose>
- <xsl:when test="/instance/os/@platform = 'linux'">
- <!-- Linux-specific configuration -->
+ <xsl:when test="/instance/os/@platform = 'linux' and /instance/backing/root/@type = 'image'">
+ <!-- for Linux image-store-based instances -->
<xsl:if test="/instance/hypervisor/@type = 'xen'">
<type>linux</type>
</xsl:if>
@@ -56,21 +56,21 @@ that describes a Eucalyptus instance to be launched.
</xsl:otherwise>
</xsl:choose>
</xsl:when>
- <xsl:when test="/instance/os/@platform = 'windows'">
- <!-- Windows-specific configuration -->
+ <xsl:when test="/instance/os/@platform = 'windows' or /instance/backing/root/@type = 'ebs'">
+ <!-- for all Windows and EBS-backed-root Linux instances -->
<type>hvm</type>
<xsl:if test="/instance/hypervisor/@type = 'xen'">
<loader>/usr/lib/xen/boot/hvmloader</loader>
</xsl:if>
</xsl:when>
<xsl:otherwise>
- <xsl:message terminate="yes">ERROR: invalid or unset /instance/os/@platform parameter</xsl:message>
+ <xsl:message terminate="yes">ERROR: invalid or unset /instance/os/@platform or /instance/backing/root/@type parameter</xsl:message>
</xsl:otherwise>
</xsl:choose>
</os>
<features>
<acpi/>
- <xsl:if test="/instance/hypervisor/@type = 'xen' and /instance/os/@platform = 'windows'">
+ <xsl:if test="/instance/hypervisor/@type = 'xen' and ( /instance/os/@platform = 'windows' or /instance/backing/root/@type = 'ebs' )">
<apic/>
<pae/>
</xsl:if>
@@ -86,7 +86,7 @@ that describes a Eucalyptus instance to be launched.
<xsl:value-of select="/instance/memoryKB"/>
</memory>
<devices>
- <xsl:if test="/instance/hypervisor/@type = 'xen' and /instance/os/@platform = 'windows'">
+ <xsl:if test="/instance/hypervisor/@type = 'xen' and ( /instance/os/@platform = 'windows' or /instance/backing/root/@type = 'ebs' )">
<xsl:choose>
<xsl:when test="/instance/hypervisor/@bitness = '32'">
<emulator>/usr/lib/xen/bin/qemu-dm</emulator>
@@ -96,7 +96,9 @@ that describes a Eucalyptus instance to be launched.
</xsl:otherwise>
</xsl:choose>
</xsl:if>
- <!-- disks -->
+
+ <!-- disks or partitions (Xen) -->
+
<xsl:for-each select="/instance/disks/diskPath">
<disk>
<xsl:attribute name="device">
@@ -134,7 +136,7 @@ that describes a Eucalyptus instance to be launched.
</xsl:call-template>
</xsl:attribute>
</xsl:when>
- <xsl:when test="/instance/hypervisor/@type='xen' and /instance/os/@platform='windows'">
+ <xsl:when test="/instance/hypervisor/@type='xen' and ( /instance/os/@platform='windows' or /instance/backing/root/@type = 'ebs' )">
<xsl:attribute name="bus">xen</xsl:attribute>
<xsl:attribute name="dev">
<xsl:call-template name="string-replace-all">
@@ -176,7 +178,9 @@ that describes a Eucalyptus instance to be launched.
<target dev="fda"/>
</disk>
</xsl:if>
+
<!-- network cards -->
+
<xsl:for-each select="/instance/nics/nic">
<interface type="bridge">
<source>
@@ -205,7 +209,11 @@ that describes a Eucalyptus instance to be launched.
</xsl:if>
</interface>
</xsl:for-each>
- <xsl:if test="/instance/hypervisor/@type = 'kvm'">
+
+ <!-- console -->
+
+ <xsl:choose>
+ <xsl:when test="/instance/hypervisor/@type = 'kvm'">
<serial type="file">
<source>
<xsl:attribute name="path">
@@ -214,15 +222,19 @@ that describes a Eucalyptus instance to be launched.
</source>
<target port="1"/>
</serial>
- </xsl:if>
- <xsl:if test="/instance/hypervisor/@type = 'xen' and /instance/os/@platform = 'windows'">
+ </xsl:when>
+ <xsl:when test="/instance/hypervisor/@type = 'xen' and /instance/os/@platform = 'windows'">
<serial type="pty">
<source path="/dev/pts/3"/>
<target port="0"/>
</serial>
<input type="tablet" bus="usb"/>
<input type="mouse" bus="ps2"/>
- </xsl:if>
+ </xsl:when>
+ <xsl:when test="/instance/hypervisor/@type = 'xen' and /instance/backing/root/@type = 'ebs'">
+ <console type="pty"/>
+ </xsl:when>
+ </xsl:choose>
<!-- <graphics type='vnc' port='-1' autoport='yes' keymap='en-us' listen='0.0.0.0'/> -->
</devices>
</domain>
View
11 util/data.h
@@ -174,6 +174,15 @@ typedef enum _ncResourceType {
NC_RESOURCE_EBS
} ncResourceType;
+static char * ncResourceTypeName [] = {
+ "image",
+ "ramdisk",
+ "kernel",
+ "ephemeral",
+ "swap",
+ "ebs"
+};
+
typedef enum _ncResourceLocationType {
NC_LOCATION_URL,
NC_LOCATION_WALRUS,
@@ -217,7 +226,7 @@ typedef struct virtualBootRecord_t {
typedef struct virtualMachine_t {
int mem, cores, disk;
char name[64];
- virtualBootRecord * image;
+ virtualBootRecord * root;
virtualBootRecord * kernel;
virtualBootRecord * ramdisk;
virtualBootRecord * swap;
Please sign in to comment.
Something went wrong with that request. Please try again.