DanB pointed out that my sexpr xend_internal patch from yesterday broke one of

the regression tests.  The problem is that the xenDaemonFormatSxpr{Disk,Net}
functions are shared between domain creation time and attaching disk time.
Unfortunately, though, Xend expects something different during these two times.
 During domain creation time, it wants the "(device" in front of the sexpr,
while during attach time it does not.  To remedy this situation, I added a flag
to these two functions to differentiate between these two modes.  With this
patch in place, all of the regression tests pass.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
This commit is contained in:
Chris Lalancette 2008-08-06 11:26:47 +00:00
parent 6335c2a0cc
commit b8fb68be37
2 changed files with 31 additions and 8 deletions

View File

@ -1,3 +1,10 @@
Wed Aug 6 13:24:00 CEST 2008 Chris Lalancette <clalance@redhat.com>
* src/xend_internal.c: Oops. My bug fix from yesterday broke the
regressions suite. We do actually need "(device" on the front of
the sexpr, but only if we are first creating the domain, not when
we are attaching a new disk. This patch fixes it by adding a flag
that we check, and allows the regression suite to pass.
Tue Aug 5 18:43:00 CEST 2008 Chris Lalancette <clalance@redhat.com>
* src/xend_internal.c: Fix three bugs related to virsh attach-disk:
a) make sure to break in the xenDaemonAttachDevice() in the switch

View File

@ -91,13 +91,15 @@ xenDaemonFormatSxprDisk(virConnectPtr conn ATTRIBUTE_UNUSED,
virDomainDiskDefPtr def,
virBufferPtr buf,
int hvm,
int xendConfigVersion);
int xendConfigVersion,
int isAttach);
static int
xenDaemonFormatSxprNet(virConnectPtr conn ATTRIBUTE_UNUSED,
virDomainNetDefPtr def,
virBufferPtr buf,
int hvm,
int xendConfigVersion);
int xendConfigVersion,
int isAttach);
static int
virDomainXMLDevID(virDomainPtr domain,
virDomainDeviceDefPtr dev,
@ -3898,7 +3900,7 @@ xenDaemonAttachDevice(virDomainPtr domain, const char *xml)
dev->data.disk,
&buf,
STREQ(def->os.type, "hvm") ? 1 : 0,
priv->xendConfigVersion) < 0)
priv->xendConfigVersion, 1) < 0)
goto cleanup;
break;
@ -3907,7 +3909,7 @@ xenDaemonAttachDevice(virDomainPtr domain, const char *xml)
dev->data.net,
&buf,
STREQ(def->os.type, "hvm") ? 1 : 0,
priv->xendConfigVersion) < 0)
priv->xendConfigVersion, 1) < 0)
goto cleanup;
break;
@ -5017,7 +5019,8 @@ xenDaemonFormatSxprDisk(virConnectPtr conn ATTRIBUTE_UNUSED,
virDomainDiskDefPtr def,
virBufferPtr buf,
int hvm,
int xendConfigVersion)
int xendConfigVersion,
int isAttach)
{
/* Xend (all versions) put the floppy device config
* under the hvm (image (os)) block
@ -5032,6 +5035,9 @@ xenDaemonFormatSxprDisk(virConnectPtr conn ATTRIBUTE_UNUSED,
xendConfigVersion == 1)
return 0;
if (!isAttach)
virBufferAddLit(buf, "(device ");
/* Normally disks are in a (device (vbd ...)) block
* but blktap disks ended up in a differently named
* (device (tap ....)) block.... */
@ -5085,6 +5091,9 @@ xenDaemonFormatSxprDisk(virConnectPtr conn ATTRIBUTE_UNUSED,
else
virBufferAddLit(buf, "(mode 'w')");
if (!isAttach)
virBufferAddLit(buf, ")");
virBufferAddLit(buf, ")");
return 0;
@ -5109,7 +5118,8 @@ xenDaemonFormatSxprNet(virConnectPtr conn,
virDomainNetDefPtr def,
virBufferPtr buf,
int hvm,
int xendConfigVersion)
int xendConfigVersion,
int isAttach)
{
if (def->type != VIR_DOMAIN_NET_TYPE_BRIDGE &&
def->type != VIR_DOMAIN_NET_TYPE_NETWORK &&
@ -5119,6 +5129,9 @@ xenDaemonFormatSxprNet(virConnectPtr conn,
return -1;
}
if (!isAttach)
virBufferAddLit(buf, "(device ");
virBufferAddLit(buf, "(vif ");
virBufferVSprintf(buf,
@ -5179,6 +5192,9 @@ xenDaemonFormatSxprNet(virConnectPtr conn,
if ((hvm) && (xendConfigVersion < 4))
virBufferAddLit(buf, "(type ioemu)");
if (!isAttach)
virBufferAddLit(buf, ")");
virBufferAddLit(buf, ")");
return 0;
@ -5439,14 +5455,14 @@ xenDaemonFormatSxpr(virConnectPtr conn,
disk = def->disks;
while (disk) {
if (xenDaemonFormatSxprDisk(conn, disk, &buf, hvm, xendConfigVersion) < 0)
if (xenDaemonFormatSxprDisk(conn, disk, &buf, hvm, xendConfigVersion, 0) < 0)
goto error;
disk = disk->next;
}
net = def->nets;
while (net) {
if (xenDaemonFormatSxprNet(conn, net, &buf, hvm, xendConfigVersion) < 0)
if (xenDaemonFormatSxprNet(conn, net, &buf, hvm, xendConfigVersion, 0) < 0)
goto error;
net = net->next;
}