# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1302276980 -3600
# Node ID 1ac49d2c7d7012c27435e78706b03272cf708efc
# Parent 892e611b47d89bf351430a0e8015fd9c9061a431
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>
Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
diff -r 892e611b47d8 -r 1ac49d2c7d70 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c Fri Apr 08 16:22:51 2011 +0100
+++ b/tools/libxl/libxl.c Fri Apr 08 16:36:20 2011 +0100
@@ -702,7 +702,6 @@
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 @@
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 @@
}
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 892e611b47d8 -r 1ac49d2c7d70 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h Fri Apr 08 16:22:51 2011 +0100
+++ b/tools/libxl/libxl.h Fri Apr 08 16:36:20 2011 +0100
@@ -412,7 +412,7 @@
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_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 892e611b47d8 -r 1ac49d2c7d70 tools/libxl/libxl.idl
--- a/tools/libxl/libxl.idl Fri Apr 08 16:22:51 2011 +0100
+++ b/tools/libxl/libxl.idl Fri Apr 08 16:36:20 2011 +0100
@@ -173,7 +173,6 @@
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_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_disk = Struct("device_disk", [
("backend_domid", uint32),
- ("domid", domid),
("pdev_path", string),
("vdev", string),
("backend", libxl_disk_backend),
@@ -216,7 +212,6 @@
libxl_device_nic = Struct("device_nic", [
("backend_domid", uint32),
- ("domid", domid),
("devid", integer),
("mtu", integer),
("model", string),
diff -r 892e611b47d8 -r 1ac49d2c7d70 tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c Fri Apr 08 16:22:51 2011 +0100
+++ b/tools/libxl/libxl_create.c Fri Apr 08 16:36:20 2011 +0100
@@ -443,7 +443,6 @@
}
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 @@
}
}
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 @@
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 @@
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 892e611b47d8 -r 1ac49d2c7d70 tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c Fri Apr 08 16:22:51 2011 +0100
+++ b/tools/libxl/libxl_dm.c Fri Apr 08 16:36:20 2011 +0100
@@ -580,22 +580,18 @@
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 @@
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 892e611b47d8 -r 1ac49d2c7d70 tools/libxl/libxl_utils.c
--- a/tools/libxl/libxl_utils.c Fri Apr 08 16:22:51 2011 +0100
+++ b/tools/libxl/libxl_utils.c Fri Apr 08 16:36:20 2011 +0100
@@ -476,7 +476,6 @@
;
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 @@
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 892e611b47d8 -r 1ac49d2c7d70 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c Fri Apr 08 16:22:51 2011 +0100
+++ b/tools/libxl/xl_cmdimpl.c Fri Apr 08 16:36:20 2011 +0100
@@ -381,7 +381,7 @@
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 @@
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 @@
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 @@
return;
}
disk.backend_domid = 0;
- disk.domid = domid;
libxl_cdrom_insert(ctx, domid, &disk);
free(buf);
@@ -4263,7 +4262,6 @@
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 @@
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 @@
return 1;
}
}
- disk.domid = fe_domid;
disk.backend_domid = be_domid;
if (libxl_device_disk_add(ctx, fe_domid, &disk)) {
@@ -4518,7 +4515,7 @@
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 892e611b47d8 -r 1ac49d2c7d70 tools/ocaml/libs/xl/xl_stubs.c
--- a/tools/ocaml/libs/xl/xl_stubs.c Fri Apr 08 16:22:51 2011 +0100
+++ b/tools/ocaml/libs/xl/xl_stubs.c Fri Apr 08 16:36:20 2011 +0100
@@ -376,7 +376,6 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|