the same switch in systemd-nspawn.
* systemd-vmspawn gained a new switch --image-format= for selecting the
- image format (i.e. support qcow2 in additin to raw) to boot
- from. --extra-drive= now takes the image format as a colon separated
+ image format (i.e. support qcow2 in additin to raw) to boot from.
+ Also --extra-drive= now takes the image format as a colon separated
parameter.
Changes in systemd-nsresourced/systemd-mountfsd:
</varlistentry>
<varlistentry>
- <term><option>--extra-drive=<replaceable>PATH</replaceable>[:<replaceable>FORMAT</replaceable>]</option></term>
+ <term><option>--extra-drive=[<replaceable>FORMAT</replaceable>:]<replaceable>PATH</replaceable></option></term>
<listitem><para>Takes a disk image or block device on the host and supplies it to the virtual
- machine as another drive. Optionally, the image format can be specified by appending a colon and
- the format (<literal>raw</literal> or <literal>qcow2</literal>). Defaults to <literal>raw</literal>.
- Note that <literal>qcow2</literal> is only supported for regular files, not block devices.</para>
+ machine as another drive. Optionally, the image format can be specified by prefixing the path with
+ <literal>raw</literal> or <literal>qcow2</literal> and a colon. The format defaults to
+ <literal>raw</literal>. Note that <literal>qcow2</literal> is only supported for regular files, not
+ block devices.</para>
<xi:include href="version-info.xml" xpointer="v256"/></listitem>
</varlistentry>
" Mount a file or directory from the host into the VM\n"
" --bind-ro=SOURCE[:TARGET]\n"
" Mount a file or directory, but read-only\n"
- " --extra-drive=PATH[:FORMAT]\n"
+ " --extra-drive=[FORMAT:]PATH\n"
" Adds an additional disk to the virtual machine\n"
- " (format: raw, qcow2; default: raw)\n"
+ " (FORMAT: raw, qcow2; default: raw)\n"
" --bind-user=NAME Bind user from host to virtual machine\n"
" --bind-user-shell=BOOL|PATH\n"
" Configure the shell to use for --bind-user= users\n"
break;
case ARG_EXTRA_DRIVE: {
- _cleanup_free_ char *buf = NULL, *drive_path = NULL;
ImageFormat format = IMAGE_FORMAT_RAW;
+ const char *dp = optarg;
- const char *colon = strrchr(optarg, ':');
+ const char *colon = strchr(dp, ':');
if (colon) {
- ImageFormat f = image_format_from_string(colon + 1);
+ _cleanup_free_ char *fs = strndup(optarg, colon - optarg);
+ if (!fs)
+ return log_oom();
+
+ ImageFormat f = image_format_from_string(fs);
if (f < 0)
- log_debug_errno(f, "Failed to parse image format '%s', assuming it is a part of path, ignoring: %m", colon + 1);
+ log_debug_errno(f, "Cannot parse '%s' as an image format, assuming it is a part of path, ignoring.", fs);
else {
format = f;
- buf = strndup(optarg, colon - optarg);
- if (!buf)
- return log_oom();
+ dp = colon + 1;
}
}
- r = parse_path_argument(buf ?: optarg, /* suppress_root= */ false, &drive_path);
+ _cleanup_free_ char *drive_path = NULL;
+ r = parse_path_argument(dp, /* suppress_root= */ false, &drive_path);
if (r < 0)
return r;