tests/nbd: pass --format to qemu-nbd if possible

Run `qemu-nbd --help` to know whether it supports --format, and if so
pass it explicitly.  This avoids warnings with newer qemu versions,
where they really recommends to explicit the format of disk images being
specified on command line.
This commit is contained in:
Pino Toscano
2015-07-21 16:56:00 +02:00
parent 42ff22a909
commit a6433aff70

View File

@@ -45,12 +45,17 @@ if (! -r $disk || -z $disk) {
exit 77
}
my $has_format_opt = system ("qemu-nbd --help | grep -q -- --format") == 0;
sub run_test {
my $readonly = shift;
my $tcp = shift;
my $server;
my @qemu_nbd = ("qemu-nbd", $disk, "-t");
if ($has_format_opt) {
push @qemu_nbd, "--format", "raw";
}
if ($tcp) {
# Choose a random port number. XXX Should check it is not in use.
my $port = int (60000 + rand (5000));