/* * Copyright 2009-2017 Citrix Ltd and other contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation; version 2.1 only. with the special * exception on linking described in file LICENSE. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. */ #include #include #include #include #include "xl.h" #include "xl_utils.h" #include "xl_parse.h" int main_blockattach(int argc, char **argv) { int opt; uint32_t fe_domid; libxl_device_disk disk; XLU_Config *config = 0; SWITCH_FOREACH_OPT(opt, "", NULL, "block-attach", 2) { /* No options */ } if (libxl_domain_qualifier_to_domid(ctx, argv[optind], &fe_domid) < 0) { fprintf(stderr, "%s is an invalid domain identifier\n", argv[optind]); return 1; } optind++; parse_disk_config_multistring (&config, argc-optind, (const char* const*)argv + optind, &disk); if (dryrun_only) { char *json = libxl_device_disk_to_json(ctx, &disk); printf("disk: %s\n", json); free(json); if (ferror(stdout) || fflush(stdout)) { perror("stdout"); exit(-1); } return 0; } if (libxl_device_disk_add(ctx, fe_domid, &disk, 0)) { fprintf(stderr, "libxl_device_disk_add failed.\n"); return 1; } return 0; } int main_blocklist(int argc, char **argv) { int opt; int i, nb; libxl_device_disk *disks; libxl_diskinfo diskinfo; SWITCH_FOREACH_OPT(opt, "", NULL, "block-list", 1) { /* No options */ } printf("%-5s %-3s %-6s %-5s %-6s %-8s %-30s\n", "Vdev", "BE", "handle", "state", "evt-ch", "ring-ref", "BE-path"); for (argv += optind, argc -= optind; argc > 0; --argc, ++argv) { uint32_t domid; if (libxl_domain_qualifier_to_domid(ctx, *argv, &domid) < 0) { fprintf(stderr, "%s is an invalid domain identifier\n", *argv); continue; } disks = libxl_device_disk_list(ctx, domid, &nb); if (!disks) { continue; } for (i=0; i