List virtual block devices for a domain.
-=item B<cd-insert> I<domain-id> I<VirtualDevice> I<be-dev>
+=item B<cd-insert> I<domain-id> I<VirtualDevice> I<target>
-Insert a cdrom into a guest domain's cd drive. Only works with HVM domains.
+Insert a cdrom into a guest domain's existing virtial cd drive. The
+virtual drive must already exist but can be current empty.
+
+Only works with HVM domains.
B<OPTIONS>
=item I<VirtualDevice>
-How the device should be presented to the guest domain; for example /dev/hdc.
+How the device should be presented to the guest domain; for example "hdc".
-=item I<be-dev>
+=item I<target>
-the device in the backend domain (usually domain 0) to be exported; it
-can be a path to a file (file://path/to/file.iso). See B<disk> in
-L<xl.cfg(5)> for the details.
+the target path in the backend domain (usually domain 0) to be
+exported; Can be a block device or a file etc. See B<target> in
+F<docs/misc/xl-disk-configuration.txt>.
=back
=item B<cd-eject> I<domain-id> I<VirtualDevice>
-Eject a cdrom from a guest's cd drive. Only works with HVM domains.
-I<VirtualDevice> is the cdrom device in the guest to eject.
+Eject a cdrom from a guest's virtual cd drive. Only works with HVM domains.
+
+B<OPTIONS>
+
+=over 4
+
+=item I<VirtualDevice>
+
+How the device should be presented to the guest domain; for example "hdc".
+
+=back
=back
EOF
one 0 backendtype=phy,vdev=xvdb,access=w,target=/dev/vg/guest-volume
+expected <<EOF
+disk: {
+ "backend_domid": 0,
+ "pdev_path": "",
+ "vdev": "hdc",
+ "backend": "unknown",
+ "format": "empty",
+ "script": null,
+ "removable": 1,
+ "readwrite": 0,
+ "is_cdrom": 1
+}
+
+EOF
+one 0 devtype=cdrom,,,hdc
+one 0 ,,hdc:cdrom,r
+one 0 vdev=hdc,access=r,devtype=cdrom,target=
+one 0 ,empty,hdc:cdrom,r
+
+expected <<EOF
+disk: {
+ "backend_domid": 0,
+ "pdev_path": null,
+ "vdev": "hdc",
+ "backend": "unknown",
+ "format": "empty",
+ "script": null,
+ "removable": 1,
+ "readwrite": 0,
+ "is_cdrom": 1
+}
+
+EOF
+one 0 vdev=hdc,access=r,devtype=cdrom,format=empty
+
complete
if (disk->is_cdrom) {
disk->removable = 1;
disk->readwrite = 0;
+ if (!disk->pdev_path || !strcmp(disk->pdev_path, ""))
+ disk->format = LIBXL_DISK_FORMAT_EMPTY;
}
if (!disk->vdev) {
/* Sets ->format from the string. IDL should provide something for this. */
static void setformat(DiskParseContext *dpc, const char *str) {
- if (!strcmp(str,"") ||
- !strcmp(str,"raw")) DSET(dpc,format,FORMAT,str,RAW);
+ if (!strcmp(str,"")) DSET(dpc,format,FORMAT,str,RAW);
+ else if (!strcmp(str,"raw")) DSET(dpc,format,FORMAT,str,RAW);
else if (!strcmp(str,"qcow")) DSET(dpc,format,FORMAT,str,QCOW);
else if (!strcmp(str,"qcow2")) DSET(dpc,format,FORMAT,str,QCOW2);
else if (!strcmp(str,"vhd")) DSET(dpc,format,FORMAT,str,VHD);
+ else if (!strcmp(str,"empty")) DSET(dpc,format,FORMAT,str,EMPTY);
else xlu__disk_err(dpc,str,"unknown value for format");
}
#define DEPRECATE(usewhatinstead) /* not currently reported */
-#line 864 "libxlu_disk_l.c"
+#line 865 "libxlu_disk_l.c"
#define INITIAL 0
#define LEXERR 1
register int yy_act;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-#line 126 "libxlu_disk_l.l"
+#line 127 "libxlu_disk_l.l"
/*----- the scanner rules which do the parsing -----*/
-#line 1105 "libxlu_disk_l.c"
+#line 1106 "libxlu_disk_l.c"
if ( !yyg->yy_init )
{
* matched the whole string, so these patterns take precedence */
case 13:
YY_RULE_SETUP
-#line 160 "libxlu_disk_l.l"
+#line 161 "libxlu_disk_l.l"
{
STRIP(':');
DPC->had_depr_prefix=1; DEPRECATE("use `[format=]...,'");
YY_BREAK
case 14:
YY_RULE_SETUP
-#line 166 "libxlu_disk_l.l"
+#line 167 "libxlu_disk_l.l"
{
STRIP(':');
DPC->had_depr_prefix=1; DEPRECATE("use `script=...'");
yyg->yy_c_buf_p = yy_cp = yy_bp + 4;
YY_DO_BEFORE_ACTION; /* set up yytext again */
YY_RULE_SETUP
-#line 174 "libxlu_disk_l.l"
+#line 175 "libxlu_disk_l.l"
{ DPC->had_depr_prefix=1; DEPRECATE(0); }
YY_BREAK
case 18:
yyg->yy_c_buf_p = yy_cp = yy_bp + 6;
YY_DO_BEFORE_ACTION; /* set up yytext again */
YY_RULE_SETUP
-#line 175 "libxlu_disk_l.l"
+#line 176 "libxlu_disk_l.l"
{ DPC->had_depr_prefix=1; DEPRECATE(0); }
YY_BREAK
case 19:
yyg->yy_c_buf_p = yy_cp = yy_bp + 5;
YY_DO_BEFORE_ACTION; /* set up yytext again */
YY_RULE_SETUP
-#line 176 "libxlu_disk_l.l"
+#line 177 "libxlu_disk_l.l"
{ DPC->had_depr_prefix=1; DEPRECATE(0); }
YY_BREAK
case 20:
case 22:
/* rule 22 can match eol */
YY_RULE_SETUP
-#line 186 "libxlu_disk_l.l"
+#line 187 "libxlu_disk_l.l"
{
char *colon;
STRIP(',');
YY_BREAK
case 23:
YY_RULE_SETUP
-#line 220 "libxlu_disk_l.l"
+#line 221 "libxlu_disk_l.l"
{
BEGIN(LEXERR);
yymore();
#define YYTABLES_NAME "yytables"
-#line 227 "libxlu_disk_l.l"
-
-/*
- * Local variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
+#line 228 "libxlu_disk_l.l"
#undef YY_DECL
#endif
-#line 227 "libxlu_disk_l.l"
+#line 228 "libxlu_disk_l.l"
#line 346 "libxlu_disk_l.h"
#undef xlu__disk_yyIN_HEADER
#endif /* xlu__disk_yyHEADER_H */
-
-/*
- * Local variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
/* Sets ->format from the string. IDL should provide something for this. */
static void setformat(DiskParseContext *dpc, const char *str) {
- if (!strcmp(str,"") ||
- !strcmp(str,"raw")) DSET(dpc,format,FORMAT,str,RAW);
+ if (!strcmp(str,"")) DSET(dpc,format,FORMAT,str,RAW);
+ else if (!strcmp(str,"raw")) DSET(dpc,format,FORMAT,str,RAW);
else if (!strcmp(str,"qcow")) DSET(dpc,format,FORMAT,str,QCOW);
else if (!strcmp(str,"qcow2")) DSET(dpc,format,FORMAT,str,QCOW2);
else if (!strcmp(str,"vhd")) DSET(dpc,format,FORMAT,str,VHD);
+ else if (!strcmp(str,"empty")) DSET(dpc,format,FORMAT,str,EMPTY);
else xlu__disk_err(dpc,str,"unknown value for format");
}
find_domain(dom);
- if (asprintf(&buf, "%s,%s:cdrom,r", phys ? phys : "", virtdev) < 0) {
+ if (asprintf(&buf, "vdev=%s,access=r,devtype=cdrom,target=%s",
+ virtdev, phys ? phys : "") < 0) {
fprintf(stderr, "out of memory\n");
return;
}
"- for internal use only",
},
{ "cd-insert",
- &main_cd_insert, 0, 1,
+ &main_cd_insert, 1, 1,
"Insert a cdrom into a guest's cd drive",
"<Domain> <VirtualDevice> <type:path>",
},
{ "cd-eject",
- &main_cd_eject, 0, 1,
+ &main_cd_eject, 1, 1,
"Eject a cdrom from a guest's cd drive",
"<Domain> <VirtualDevice>",
},