# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1302161755 -3600
# Node ID 3a1f9a001a107cd210fbf1c81e70eacc7577f987
# Parent 9c05f7fa1edd8c013b5fb2666b2706eae0dc4341
libxl: drop domid field from libxl_device_*
All functions which add a device to a domain already take a domid
argument and the callers typically write the same value to the
structure right before making the call.
Functions which delete a device typically do not but adding this field
makes the interface more consistent anyway and all callers have the
domid to hand.
All functions which return a libxl device structure are given a domid
as a paramter and the caller therefore already knows which domain it
is dealing with.
Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
diff -r 9c05f7fa1edd -r 3a1f9a001a10 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c Thu Apr 07 08:35:51 2011 +0100
+++ b/tools/libxl/libxl.c Thu Apr 07 08:35:55 2011 +0100
@@ -702,7 +702,6 @@ int libxl_event_get_disk_eject_info(libx
disk->backend = DISK_BACKEND_UNKNOWN;
}
- disk->domid = domid;
disk->pdev_path = strdup("");
disk->format = DISK_FORMAT_EMPTY;
/* this value is returned to the user: do not free right away */
@@ -977,7 +976,7 @@ int libxl_device_disk_add(libxl_ctx *ctx
device.backend_devid = devid;
device.backend_domid = disk->backend_domid;
device.devid = devid;
- device.domid = disk->domid;
+ device.domid = domid;
device.kind = DEVICE_VBD;
switch (disk->backend) {
@@ -1031,7 +1030,7 @@ int libxl_device_disk_add(libxl_ctx *ctx
}
flexarray_append(back, "frontend-id");
- flexarray_append(back, libxl__sprintf(&gc, "%d", disk->domid));
+ flexarray_append(back, libxl__sprintf(&gc, "%d", domid));
flexarray_append(back, "online");
flexarray_append(back, "1");
flexarray_append(back, "removable");
@@ -1075,7 +1074,7 @@ out:
return rc;
}
-int libxl_device_disk_del(libxl_ctx *ctx,
+int libxl_device_disk_del(libxl_ctx *ctx, uint32_t domid,
libxl_device_disk *disk, int wait)
{
libxl__gc gc = LIBXL_INIT_GC(ctx);
@@ -1087,7 +1086,7 @@ int libxl_device_disk_del(libxl_ctx *ctx
device.backend_devid = devid;
device.backend_kind =
(disk->backend == DISK_BACKEND_PHY) ? DEVICE_VBD : DEVICE_TAP;
- device.domid = disk->domid;
+ device.domid = domid;
device.devid = devid;
device.kind = DEVICE_VBD;
rc = libxl__device_del(&gc, &device, wait);
@@ -1187,7 +1186,6 @@ int libxl_device_nic_init(libxl_device_n
memset(nic_info, '\0', sizeof(*nic_info));
nic_info->backend_domid = 0;
- nic_info->domid = 0;
nic_info->devid = devnum;
nic_info->mtu = 1492;
nic_info->model = strdup("rtl8139");
@@ -1244,11 +1242,11 @@ int libxl_device_nic_add(libxl_ctx *ctx,
device.backend_domid = nic->backend_domid;
device.backend_kind = DEVICE_VIF;
device.devid = nic->devid;
- device.domid = nic->domid;
+ device.domid = domid;
device.kind = DEVICE_VIF;
flexarray_append(back, "frontend-id");
- flexarray_append(back, libxl__sprintf(&gc, "%d", nic->domid));
+ flexarray_append(back, libxl__sprintf(&gc, "%d", domid));
flexarray_append(back, "online");
flexarray_append(back, "1");
flexarray_append(back, "state");
@@ -1303,7 +1301,7 @@ out:
return rc;
}
-int libxl_device_nic_del(libxl_ctx *ctx,
+int libxl_device_nic_del(libxl_ctx *ctx, uint32_t domid,
libxl_device_nic *nic, int wait)
{
libxl__gc gc = LIBXL_INIT_GC(ctx);
@@ -1314,7 +1312,7 @@ int libxl_device_nic_del(libxl_ctx *ctx,
device.backend_domid = nic->backend_domid;
device.backend_kind = DEVICE_VIF;
device.devid = nic->devid;
- device.domid = nic->domid;
+ device.domid = domid;
device.kind = DEVICE_VIF;
rc = libxl__device_del(&gc, &device, wait);
@@ -1402,11 +1400,11 @@ int libxl_device_console_add(libxl_ctx *
device.backend_domid = console->backend_domid;
device.backend_kind = DEVICE_CONSOLE;
device.devid = console->devid;
- device.domid = console->domid;
+ device.domid = domid;
device.kind = DEVICE_CONSOLE;
flexarray_append(back, "frontend-id");
- flexarray_append(back, libxl__sprintf(&gc, "%d", console->domid));
+ flexarray_append(back, libxl__sprintf(&gc, "%d", domid));
flexarray_append(back, "online");
flexarray_append(back, "1");
flexarray_append(back, "state");
@@ -1486,11 +1484,11 @@ int libxl_device_vkb_add(libxl_ctx *ctx,
device.backend_domid = vkb->backend_domid;
device.backend_kind = DEVICE_VKBD;
device.devid = vkb->devid;
- device.domid = vkb->domid;
+ device.domid = domid;
device.kind = DEVICE_VKBD;
flexarray_append(back, "frontend-id");
- flexarray_append(back, libxl__sprintf(&gc, "%d", vkb->domid));
+ flexarray_append(back, libxl__sprintf(&gc, "%d", domid));
flexarray_append(back, "online");
flexarray_append(back, "1");
flexarray_append(back, "state");
@@ -1548,7 +1546,6 @@ static unsigned int libxl__append_disk_l
pdisk_end = *disks + *ndisks;
for (; pdisk < pdisk_end; pdisk++, dir++) {
pdisk->backend_domid = 0;
- pdisk->domid = domid;
physpath_tmp = xs_read(ctx->xsh, XBT_NULL, libxl__sprintf(gc,
"%s/%s/params", be_path, *dir), &len);
if (physpath_tmp && strchr(physpath_tmp, ':')) {
pdisk->pdev_path = strdup(strchr(physpath_tmp, ':') + 1);
@@ -1647,15 +1644,12 @@ int libxl_cdrom_insert(libxl_ctx *ctx, u
ret = 0;
- libxl_device_disk_del(ctx, disks + i, 1);
+ libxl_device_disk_del(ctx, domid, disks + i, 1);
libxl_device_disk_add(ctx, domid, disk);
stubdomid = libxl_get_stubdom_id(ctx, domid);
if (stubdomid) {
- disks[i].domid = stubdomid;
- libxl_device_disk_del(ctx, disks + i, 1);
- disk->domid = stubdomid;
+ libxl_device_disk_del(ctx, stubdomid, disks + i, 1);
libxl_device_disk_add(ctx, stubdomid, disk);
- disk->domid = domid;
}
out:
for (i = 0; i < num; i++)
@@ -1704,10 +1698,10 @@ int libxl_device_vfb_add(libxl_ctx *ctx,
device.backend_domid = vfb->backend_domid;
device.backend_kind = DEVICE_VFB;
device.devid = vfb->devid;
- device.domid = vfb->domid;
+ device.domid = domid;
device.kind = DEVICE_VFB;
- flexarray_append_pair(back, "frontend-id", libxl__sprintf(&gc, "%d",
vfb->domid));
+ flexarray_append_pair(back, "frontend-id", libxl__sprintf(&gc, "%d",
domid));
flexarray_append_pair(back, "online", "1");
flexarray_append_pair(back, "state", libxl__sprintf(&gc, "%d", 1));
flexarray_append_pair(back, "domain", libxl__domid_to_name(&gc, domid));
diff -r 9c05f7fa1edd -r 3a1f9a001a10 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h Thu Apr 07 08:35:51 2011 +0100
+++ b/tools/libxl/libxl.h Thu Apr 07 08:35:55 2011 +0100
@@ -412,7 +412,7 @@ libxl_cpupoolinfo * libxl_list_cpupool(l
libxl_vminfo * libxl_list_vm(libxl_ctx *ctx, int *nb_vm);
int libxl_device_disk_add(libxl_ctx *ctx, uint32_t domid, libxl_device_disk
*disk);
-int libxl_device_disk_del(libxl_ctx *ctx, libxl_device_disk *disk, int wait);
+int libxl_device_disk_del(libxl_ctx *ctx, uint32_t domid, libxl_device_disk
*disk, int wait);
libxl_device_disk *libxl_device_disk_list(libxl_ctx *ctx, uint32_t domid, int
*num);
int libxl_device_disk_getinfo(libxl_ctx *ctx, uint32_t domid,
libxl_device_disk *disk, libxl_diskinfo
*diskinfo);
@@ -426,7 +426,7 @@ int libxl_device_disk_local_detach(libxl
int libxl_device_nic_init(libxl_device_nic *nic, int dev_num);
int libxl_device_nic_add(libxl_ctx *ctx, uint32_t domid, libxl_device_nic
*nic);
-int libxl_device_nic_del(libxl_ctx *ctx, libxl_device_nic *nic, int wait);
+int libxl_device_nic_del(libxl_ctx *ctx, uint32_t domid, libxl_device_nic
*nic, int wait);
libxl_nicinfo *libxl_list_nics(libxl_ctx *ctx, uint32_t domid, unsigned int
*nb);
int libxl_device_console_add(libxl_ctx *ctx, uint32_t domid,
libxl_device_console *console);
diff -r 9c05f7fa1edd -r 3a1f9a001a10 tools/libxl/libxl.idl
--- a/tools/libxl/libxl.idl Thu Apr 07 08:35:51 2011 +0100
+++ b/tools/libxl/libxl.idl Thu Apr 07 08:35:55 2011 +0100
@@ -173,7 +173,6 @@ Network is missing""")
libxl_device_vfb = Struct("device_vfb", [
("backend_domid", uint32),
- ("domid", uint32),
("devid", integer),
("vnc", bool, False, "vnc enabled or disabled"),
("vnclisten", string, False, "address:port that should be listened
on for the VNC server if vnc is set"),
@@ -189,13 +188,11 @@ libxl_device_vfb = Struct("device_vfb",
libxl_device_vkb = Struct("device_vkb", [
("backend_domid", uint32),
- ("domid", domid),
("devid", integer),
])
libxl_device_console = Struct("device_console", [
("backend_domid", uint32),
- ("domid", domid),
("devid", integer),
("consback", libxl_console_consback),
("build_state", Reference(libxl_domain_build_state), True),
@@ -204,7 +201,6 @@ libxl_device_console = Struct("device_co
libxl_device_disk = Struct("device_disk", [
("backend_domid", uint32),
- ("domid", domid),
("pdev_path", string),
("vdev", string),
("backend", libxl_disk_backend),
@@ -216,7 +212,6 @@ libxl_device_disk = Struct("device_disk"
libxl_device_nic = Struct("device_nic", [
("backend_domid", uint32),
- ("domid", domid),
("devid", integer),
("mtu", integer),
("model", string),
diff -r 9c05f7fa1edd -r 3a1f9a001a10 tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c Thu Apr 07 08:35:51 2011 +0100
+++ b/tools/libxl/libxl_create.c Thu Apr 07 08:35:55 2011 +0100
@@ -443,7 +443,6 @@ static int do_domain_create(libxl__gc *g
}
for (i = 0; i < d_config->num_disks; i++) {
- d_config->disks[i].domid = domid;
ret = libxl_device_disk_add(ctx, domid, &d_config->disks[i]);
if (ret) {
fprintf(stderr, "cannot add disk %d to domain: %d\n", i, ret);
@@ -452,7 +451,6 @@ static int do_domain_create(libxl__gc *g
}
}
for (i = 0; i < d_config->num_vifs; i++) {
- d_config->vifs[i].domid = domid;
ret = libxl_device_nic_add(ctx, domid, &d_config->vifs[i]);
if (ret) {
fprintf(stderr, "cannot add nic %d to domain: %d\n", i, ret);
@@ -466,7 +464,6 @@ static int do_domain_create(libxl__gc *g
ret = init_console_info(&console, 0, &state);
if ( ret )
goto error_out;
- console.domid = domid;
libxl_device_console_add(ctx, domid, &console);
libxl_device_console_destroy(&console);
@@ -485,16 +482,13 @@ static int do_domain_create(libxl__gc *g
libxl_device_console console;
for (i = 0; i < d_config->num_vfbs; i++) {
- d_config->vfbs[i].domid = domid;
libxl_device_vfb_add(ctx, domid, &d_config->vfbs[i]);
- d_config->vkbs[i].domid = domid;
libxl_device_vkb_add(ctx, domid, &d_config->vkbs[i]);
}
ret = init_console_info(&console, 0, &state);
if ( ret )
goto error_out;
- console.domid = domid;
need_qemu = libxl__need_xenpv_qemu(gc, 1, &console,
d_config->num_vfbs, d_config->vfbs,
diff -r 9c05f7fa1edd -r 3a1f9a001a10 tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c Thu Apr 07 08:35:51 2011 +0100
+++ b/tools/libxl/libxl_dm.c Thu Apr 07 08:35:55 2011 +0100
@@ -580,22 +580,18 @@ retry_transaction:
goto retry_transaction;
for (i = 0; i < num_disks; i++) {
- disks[i].domid = domid;
ret = libxl_device_disk_add(ctx, domid, &disks[i]);
if (ret)
goto out_free;
}
for (i = 0; i < num_vifs; i++) {
- vifs[i].domid = domid;
ret = libxl_device_nic_add(ctx, domid, &vifs[i]);
if (ret)
goto out_free;
}
- vfb->domid = domid;
ret = libxl_device_vfb_add(ctx, domid, vfb);
if (ret)
goto out_free;
- vkb->domid = domid;
ret = libxl_device_vkb_add(ctx, domid, vkb);
if (ret)
goto out_free;
@@ -612,7 +608,6 @@ retry_transaction:
for (i = 0; i < num_console; i++) {
console[i].devid = i;
console[i].consback = LIBXL_CONSBACK_IOEMU;
- console[i].domid = domid;
/* STUBDOM_CONSOLE_LOGGING (console 0) is for minios logging
* STUBDOM_CONSOLE_SAVE (console 1) is for writing the save file
* STUBDOM_CONSOLE_RESTORE (console 2) is for reading the save file
diff -r 9c05f7fa1edd -r 3a1f9a001a10 tools/libxl/libxl_utils.c
--- a/tools/libxl/libxl_utils.c Thu Apr 07 08:35:51 2011 +0100
+++ b/tools/libxl/libxl_utils.c Thu Apr 07 08:35:55 2011 +0100
@@ -476,7 +476,6 @@ int libxl_mac_to_device_nic(libxl_ctx *c
;
if ((b >= mac_n + 6) && (*a == *b)) {
nic->backend_domid = nics[i].backend_id;
- nic->domid = nics[i].frontend_id;
nic->devid = nics[i].devid;
memcpy(nic->mac, nics[i].mac, sizeof (nic->mac));
nic->script = strdup(nics[i].script);
@@ -551,7 +550,6 @@ int libxl_devid_to_device_disk(libxl_ctx
if (!val)
goto out;
disk->backend_domid = strtoul(val, NULL, 10);
- disk->domid = domid;
be_path = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/backend",
diskpath));
disk->pdev_path = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc,
"%s/params", be_path));
val = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/type",
be_path));
diff -r 9c05f7fa1edd -r 3a1f9a001a10 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c Thu Apr 07 08:35:51 2011 +0100
+++ b/tools/libxl/xl_cmdimpl.c Thu Apr 07 08:35:55 2011 +0100
@@ -381,7 +381,7 @@ static void printf_info(int domid,
printf("\t(device\n");
printf("\t\t(tap\n");
printf("\t\t\t(backend_domid %d)\n", d_config->disks[i].backend_domid);
- printf("\t\t\t(domid %d)\n", d_config->disks[i].domid);
+ printf("\t\t\t(domid %d)\n", domid);
printf("\t\t\t(physpath %s)\n", d_config->disks[i].pdev_path);
printf("\t\t\t(phystype %d)\n", d_config->disks[i].backend);
printf("\t\t\t(virtpath %s)\n", d_config->disks[i].vdev);
@@ -396,7 +396,7 @@ static void printf_info(int domid,
printf("\t(device\n");
printf("\t\t(vif\n");
printf("\t\t\t(backend_domid %d)\n", d_config->vifs[i].backend_domid);
- printf("\t\t\t(domid %d)\n", d_config->vifs[i].domid);
+ printf("\t\t\t(domid %d)\n", domid);
printf("\t\t\t(devid %d)\n", d_config->vifs[i].devid);
printf("\t\t\t(mtu %d)\n", d_config->vifs[i].mtu);
printf("\t\t\t(model %s)\n", d_config->vifs[i].model);
@@ -426,7 +426,7 @@ static void printf_info(int domid,
printf("\t(device\n");
printf("\t\t(vfb\n");
printf("\t\t\t(backend_domid %d)\n", d_config->vfbs[i].backend_domid);
- printf("\t\t\t(domid %d)\n", d_config->vfbs[i].domid);
+ printf("\t\t\t(domid %d)\n", domid);
printf("\t\t\t(devid %d)\n", d_config->vfbs[i].devid);
printf("\t\t\t(vnc %d)\n", d_config->vfbs[i].vnc);
printf("\t\t\t(vnclisten %s)\n", d_config->vfbs[i].vnclisten);
@@ -1844,7 +1844,6 @@ static void cd_insert(const char *dom, c
return;
}
disk.backend_domid = 0;
- disk.domid = domid;
libxl_cdrom_insert(ctx, domid, &disk);
free(buf);
@@ -4263,7 +4262,6 @@ int main_networkattach(int argc, char **
return 1;
}
}
- nic.domid = domid;
if (libxl_device_nic_add(ctx, domid, &nic)) {
fprintf(stderr, "libxl_device_nic_add failed.\n");
return 1;
@@ -4358,7 +4356,7 @@ int main_networkdetach(int argc, char **
return 1;
}
}
- if (libxl_device_nic_del(ctx, &nic, 1)) {
+ if (libxl_device_nic_del(ctx, domid, &nic, 1)) {
fprintf(stderr, "libxl_device_nic_del failed.\n");
return 1;
}
@@ -4433,7 +4431,6 @@ int main_blockattach(int argc, char **ar
return 1;
}
}
- disk.domid = fe_domid;
disk.backend_domid = be_domid;
if (libxl_device_disk_add(ctx, fe_domid, &disk)) {
@@ -4518,7 +4515,7 @@ int main_blockdetach(int argc, char **ar
fprintf(stderr, "Error: Device %s not connected.\n", argv[optind+1]);
return 1;
}
- if (libxl_device_disk_del(ctx, &disk, 1)) {
+ if (libxl_device_disk_del(ctx, domid, &disk, 1)) {
fprintf(stderr, "libxl_device_disk_del failed.\n");
}
return 0;
diff -r 9c05f7fa1edd -r 3a1f9a001a10 tools/ocaml/libs/xl/xl_stubs.c
--- a/tools/ocaml/libs/xl/xl_stubs.c Thu Apr 07 08:35:51 2011 +0100
+++ b/tools/ocaml/libs/xl/xl_stubs.c Thu Apr 07 08:35:55 2011 +0100
@@ -376,7 +376,6 @@ value stub_xl_disk_add(value info, value
INIT_STRUCT();
device_disk_val(&gc, &c_info, info);
- c_info.domid = Int_val(domid);
INIT_CTX();
ret = libxl_device_disk_add(ctx, Int_val(domid), &c_info);
@@ -394,10 +393,9 @@ value stub_xl_disk_remove(value info, va
INIT_STRUCT();
device_disk_val(&gc, &c_info, info);
- c_info.domid = Int_val(domid);
INIT_CTX();
- ret = libxl_device_disk_del(ctx, &c_info, 0);
+ ret = libxl_device_disk_del(ctx, Int_val(domid), &c_info, 0);
if (ret != 0)
failwith_xl("disk_remove", &lg);
FREE_CTX();
@@ -412,7 +410,6 @@ value stub_xl_nic_add(value info, value
INIT_STRUCT();
device_nic_val(&gc, &c_info, info);
- c_info.domid = Int_val(domid);
INIT_CTX();
ret = libxl_device_nic_add(ctx, Int_val(domid), &c_info);
@@ -430,10 +427,9 @@ value stub_xl_nic_remove(value info, val
INIT_STRUCT();
device_nic_val(&gc, &c_info, info);
- c_info.domid = Int_val(domid);
INIT_CTX();
- ret = libxl_device_nic_del(ctx, &c_info, 0);
+ ret = libxl_device_nic_del(ctx, Int_val(domid), &c_info, 0);
if (ret != 0)
failwith_xl("nic_remove", &lg);
FREE_CTX();
@@ -450,7 +446,6 @@ value stub_xl_console_add(value info, va
device_console_val(&gc, &c_info, info);
domain_build_state_val(&gc, &c_state, state);
- c_info.domid = Int_val(domid);
c_info.build_state = &c_state;
INIT_CTX();
@@ -469,7 +464,6 @@ value stub_xl_vkb_add(value info, value
INIT_STRUCT();
device_vkb_val(&gc, &c_info, info);
- c_info.domid = Int_val(domid);
INIT_CTX();
ret = libxl_device_vkb_add(ctx, Int_val(domid), &c_info);
@@ -518,7 +512,6 @@ value stub_xl_vfb_add(value info, value
INIT_STRUCT();
device_vfb_val(&gc, &c_info, info);
- c_info.domid = Int_val(domid);
INIT_CTX();
ret = libxl_device_vfb_add(ctx, Int_val(domid), &c_info);
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|