int xen_config_dev_blk(DriveInfo *disk)

{

    char fe[256], be[256];

    int vdev = 202 * 256 + 16 * disk->unit;

    int cdrom = disk->bdrv->type == BDRV_TYPE_CDROM;

    const char *devtype = cdrom ? "cdrom" : "disk";

    const char *mode    = cdrom ? "r"     : "w";



    snprintf(disk->bdrv->device_name, sizeof(disk->bdrv->device_name),

	     "xvd%c", 'a' + disk->unit);

    xen_be_printf(NULL, 1, "config disk %d [%s]: %s\n",

                  disk->unit, disk->bdrv->device_name, disk->bdrv->filename);

    xen_config_dev_dirs("vbd", "qdisk", vdev, fe, be, sizeof(fe));



    /* frontend */

    xenstore_write_int(fe, "virtual-device",  vdev);

    xenstore_write_str(fe, "device-type",     devtype);



    /* backend */

    xenstore_write_str(be, "dev",             disk->bdrv->device_name);

    xenstore_write_str(be, "type",            "file");

    xenstore_write_str(be, "params",          disk->bdrv->filename);

    xenstore_write_str(be, "mode",            mode);



    /* common stuff */

    return xen_config_dev_all(fe, be);

}

int xen_config_dev_blk(DriveInfo *disk)

{

    char fe[256], be[256];

    int vdev = 202 * 256 + 16 * disk->unit;

    int cdrom = disk->bdrv->type == BDRV_TYPE_CDROM;

    const char *devtype = cdrom ? "cdrom" : "disk";

    const char *mode    = cdrom ? "r"     : "w";



    snprintf(disk->bdrv->device_name, sizeof(disk->bdrv->device_name),

	     "xvd%c", 'a' + disk->unit);

    xen_be_printf(NULL, 1, "config disk %d [%s]: %s\n",

                  disk->unit, disk->bdrv->device_name, disk->bdrv->filename);

    xen_config_dev_dirs("vbd", "qdisk", vdev, fe, be, sizeof(fe));



    

    xenstore_write_int(fe, "virtual-device",  vdev);

    xenstore_write_str(fe, "device-type",     devtype);



    

    xenstore_write_str(be, "dev",             disk->bdrv->device_name);

    xenstore_write_str(be, "type",            "file");

    xenstore_write_str(be, "params",          disk->bdrv->filename);

    xenstore_write_str(be, "mode",            mode);



    

    return xen_config_dev_all(fe, be);

}

int FUNC_0(DriveInfo *VAR_0)

{

    char VAR_1[256], VAR_2[256];

    int VAR_3 = 202 * 256 + 16 * VAR_0->unit;

    int VAR_4 = VAR_0->bdrv->type == BDRV_TYPE_CDROM;

    const char *VAR_5 = VAR_4 ? "VAR_4" : "VAR_0";

    const char *VAR_6    = VAR_4 ? "r"     : "w";



    snprintf(VAR_0->bdrv->device_name, sizeof(VAR_0->bdrv->device_name),

	     "xvd%c", 'a' + VAR_0->unit);

    xen_be_printf(NULL, 1, "config VAR_0 %d [%s]: %s\n",

                  VAR_0->unit, VAR_0->bdrv->device_name, VAR_0->bdrv->filename);

    xen_config_dev_dirs("vbd", "qdisk", VAR_3, VAR_1, VAR_2, sizeof(VAR_1));



    

    xenstore_write_int(VAR_1, "virtual-device",  VAR_3);

    xenstore_write_str(VAR_1, "device-type",     VAR_5);



    

    xenstore_write_str(VAR_2, "dev",             VAR_0->bdrv->device_name);

    xenstore_write_str(VAR_2, "type",            "file");

    xenstore_write_str(VAR_2, "params",          VAR_0->bdrv->filename);

    xenstore_write_str(VAR_2, "VAR_6",            VAR_6);



    

    return xen_config_dev_all(VAR_1, VAR_2);

}

int FUNC_0(DriveInfo *VAR_0)
{ char VAR_1[256], VAR_2[256]; int VAR_3 = 202 * 256 + 16 * VAR_0->unit; int VAR_4 = VAR_0->bdrv->type == BDRV_TYPE_CDROM; const char *VAR_5 = VAR_4 ? "VAR_4" : "VAR_0"; const char *VAR_6    = VAR_4 ? "r"     : "w"; snprintf(VAR_0->bdrv->device_name, sizeof(VAR_0->bdrv->device_name),
"xvd%c", 'a' + VAR_0->unit); xen_be_printf(NULL, 1, "config VAR_0 %d [%s]: %s\n",
VAR_0->unit, VAR_0->bdrv->device_name, VAR_0->bdrv->filename); xen_config_dev_dirs("vbd", "qdisk", VAR_3, VAR_1, VAR_2, sizeof(VAR_1)); xenstore_write_int(VAR_1, "virtual-device",  VAR_3); xenstore_write_str(VAR_1, "device-type",     VAR_5); xenstore_write_str(VAR_2, "dev",             VAR_0->bdrv->device_name); xenstore_write_str(VAR_2, "type",            "file"); xenstore_write_str(VAR_2, "params",          VAR_0->bdrv->filename); xenstore_write_str(VAR_2, "VAR_6",            VAR_6); return xen_config_dev_all(VAR_1, VAR_2); }