Don't rely on the /dev entry in the xenstore to get the handle; extract

it from the xenstore path. /dev will have whatever is in the guest's config
file disk entry, and this may not be a number (in the case of HVM guests
it's a string starting with 'ioemu').
This commit is contained in:
bouyer 2006-10-15 21:34:48 +00:00
parent 5bc3ea6c79
commit 593919aafc

View File

@ -1,4 +1,4 @@
/* $NetBSD: xbdback_xenbus.c,v 1.1 2006/07/02 16:35:24 bouyer Exp $ */
/* $NetBSD: xbdback_xenbus.c,v 1.2 2006/10/15 21:34:48 bouyer Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@ -289,7 +289,8 @@ xbdback_xenbus_create(struct xenbus_device *xbusd)
{
struct xbdback_instance *xbdi;
long domid, handle;
int error;
int error, i;
char *ep;
if ((error = xenbus_read_ul(NULL, xbusd->xbusd_path,
"frontend-id", &domid, 10)) != 0) {
@ -297,11 +298,26 @@ xbdback_xenbus_create(struct xenbus_device *xbusd)
xbusd->xbusd_path, error);
return error;
}
if ((error = xenbus_read_ul(NULL, xbusd->xbusd_path,
"dev", &handle, 16)) != 0) {
aprint_error("xbdback: can' read %s/handle: %d\n",
xbusd->xbusd_path, error);
return error;
/*
* get handle: this is the last component of the path; which is
* a decimal number. $path/dev contains the device name, which is not
* appropriate.
*/
for (i = strlen(xbusd->xbusd_path); i > 0; i--) {
if (xbusd->xbusd_path[i] == '/')
break;
}
if (i == 0) {
aprint_error("xbdback: can't parse %s\n",
xbusd->xbusd_path);
return EFTYPE;
}
handle = strtoul(&xbusd->xbusd_path[i+1], &ep, 10);
if (*ep != '\0') {
aprint_error("xbdback: can't parse %s\n",
xbusd->xbusd_path);
return EFTYPE;
}
if (xbdif_lookup(domid, handle) != NULL) {