summaryrefslogtreecommitdiffstats
path: root/mdk-stage1
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mageia.org>2012-01-26 18:58:23 +0000
committerThierry Vignaud <tv@mageia.org>2012-01-26 18:58:23 +0000
commit9d65c4036608eb4d74971c4bf400640ffb067a55 (patch)
treedb45153d7d33e722a73f14289185b4788384c6fc /mdk-stage1
parent4df9dbe615418813d2af68c7af09aeb353c53a2a (diff)
downloaddrakx-backup-do-not-use-9d65c4036608eb4d74971c4bf400640ffb067a55.tar
drakx-backup-do-not-use-9d65c4036608eb4d74971c4bf400640ffb067a55.tar.gz
drakx-backup-do-not-use-9d65c4036608eb4d74971c4bf400640ffb067a55.tar.bz2
drakx-backup-do-not-use-9d65c4036608eb4d74971c4bf400640ffb067a55.tar.xz
drakx-backup-do-not-use-9d65c4036608eb4d74971c4bf400640ffb067a55.zip
(ensure_dev_exists,find_media) add support for virtio discs
Diffstat (limited to 'mdk-stage1')
-rw-r--r--mdk-stage1/NEWS2
-rw-r--r--mdk-stage1/mount.c12
-rw-r--r--mdk-stage1/probing.c35
3 files changed, 49 insertions, 0 deletions
diff --git a/mdk-stage1/NEWS b/mdk-stage1/NEWS
index 09a8fae6e..11e076517 100644
--- a/mdk-stage1/NEWS
+++ b/mdk-stage1/NEWS
@@ -1,3 +1,5 @@
+- add support for virtio discs
+
1.59
- try to use arch-prefixed location for FTP & HTTP installs (mga#2578)
diff --git a/mdk-stage1/mount.c b/mdk-stage1/mount.c
index 38a17fcf1..8fd91ee2f 100644
--- a/mdk-stage1/mount.c
+++ b/mdk-stage1/mount.c
@@ -60,6 +60,18 @@ int ensure_dev_exists(const char * dev)
}
} else if (name[3])
minor += (name[3] - '0');
+ } else if (ptr_begins_static_str(name, "vd")) {
+ /* Virtual disks */
+ major = 252;
+ minor = (name[2] - 'a') << 4;
+ if (name[3] && name[4]) {
+ minor += 10 + (name[4] - '0');
+ if (name[3] > 1 || name[4] > 5) {
+ log_message("I don't know how to create device %s, please post bugreport to me!", dev);
+ return -1;
+ }
+ } else if (name[3])
+ minor += (name[3] - '0');
} else if (ptr_begins_static_str(name, "hd")) {
/* IDE disks/cd's */
if (name[2] == 'a')
diff --git a/mdk-stage1/probing.c b/mdk-stage1/probing.c
index 6b969300b..ff5b02994 100644
--- a/mdk-stage1/probing.c
+++ b/mdk-stage1/probing.c
@@ -866,6 +866,41 @@ void find_media(enum media_bus bus)
fclose(f);
}
}
+ /* ----------------------------------------------- */
+ log_message("looking for VirtIO");
+ {
+ int fd, i;
+ char b[50];
+ char *name = b+11;
+ strcpy(b, "/sys/block/vd");
+ for (b[13] = 'a'; b[13] <= 'c'; b[13]++) {
+ /* first, test if file exists (will tell if attached medium exists) */
+ b[14] = '\0';
+ if (access(b, R_OK))
+ continue;
+
+ tmp[count].name = strdup(name);
+ tmp[count].type = DISK; //UNKNOWN_MEDIA;
+ tmp[count].model = strdup("VirtIO disk");
+
+ /* media type */
+ strcpy(b + 14, "/capability");
+ fd = open(b, O_RDONLY);
+ if (fd == -1) {
+ log_message("failed to open %s for reading", b);
+ //continue;
+ }
+ i = read(fd, buf, sizeof(buf));
+ if (i == -1) {
+ log_message("Couldn't read capabilities file (%s)", b);
+ } else {
+ if (!strcmp(buf, "10"))
+ tmp[count].type = DISK;
+ }
+
+ count++;
+ }
+ }
find_media_after_scsi:
/* ----------------------------------------------- */