Revision b7eb0c9f hw/block-common.c
b/hw/block-common.c | ||
---|---|---|
9 | 9 |
|
10 | 10 |
#include "blockdev.h" |
11 | 11 |
#include "hw/block-common.h" |
12 |
#include "qemu-error.h" |
|
12 | 13 |
|
13 | 14 |
void blkconf_serial(BlockConf *conf, char **serial) |
14 | 15 |
{ |
... | ... | |
22 | 23 |
} |
23 | 24 |
} |
24 | 25 |
} |
26 |
|
|
27 |
int blkconf_geometry(BlockConf *conf, int *ptrans, |
|
28 |
unsigned cyls_max, unsigned heads_max, unsigned secs_max) |
|
29 |
{ |
|
30 |
DriveInfo *dinfo; |
|
31 |
|
|
32 |
if (!conf->cyls && !conf->heads && !conf->secs) { |
|
33 |
/* try to fall back to value set with legacy -drive cyls=... */ |
|
34 |
dinfo = drive_get_by_blockdev(conf->bs); |
|
35 |
conf->cyls = dinfo->cyls; |
|
36 |
conf->heads = dinfo->heads; |
|
37 |
conf->secs = dinfo->secs; |
|
38 |
if (ptrans) { |
|
39 |
*ptrans = dinfo->trans; |
|
40 |
} |
|
41 |
} |
|
42 |
if (!conf->cyls && !conf->heads && !conf->secs) { |
|
43 |
hd_geometry_guess(conf->bs, |
|
44 |
&conf->cyls, &conf->heads, &conf->secs, |
|
45 |
ptrans); |
|
46 |
} else if (ptrans && *ptrans == BIOS_ATA_TRANSLATION_AUTO) { |
|
47 |
*ptrans = hd_bios_chs_auto_trans(conf->cyls, conf->heads, conf->secs); |
|
48 |
} |
|
49 |
if (conf->cyls || conf->heads || conf->secs) { |
|
50 |
if (conf->cyls < 1 || conf->cyls > cyls_max) { |
|
51 |
error_report("cyls must be between 1 and %u", cyls_max); |
|
52 |
return -1; |
|
53 |
} |
|
54 |
if (conf->heads < 1 || conf->heads > heads_max) { |
|
55 |
error_report("heads must be between 1 and %u", heads_max); |
|
56 |
return -1; |
|
57 |
} |
|
58 |
if (conf->secs < 1 || conf->secs > secs_max) { |
|
59 |
error_report("secs must be between 1 and %u", secs_max); |
|
60 |
return -1; |
|
61 |
} |
|
62 |
} |
|
63 |
return 0; |
|
64 |
} |
Also available in: Unified diff