Drive add » История » Версия 6
Андрей Волков, 2015-08-18 21:36
1 | 1 | Андрей Волков | h1. Добавление диска в QMP Shell |
---|---|---|---|
2 | |||
3 | h2. Создаем новый раздел на хост системе |
||
4 | |||
5 | host # *lvcreate -L 7g -n qemu319-panda-root safespace* |
||
6 | |||
7 | <pre> |
||
8 | Logical volume "qemu319-panda-root" created |
||
9 | </pre> |
||
10 | |||
11 | h2. Выставляем нужные права на устройство |
||
12 | |||
13 | host # *chown qemu319 /dev/safespace/qemu319-panda-root* |
||
14 | |||
15 | Это нужно чтобы виртуальная машина могла прочитать блочное устройство от имени непривилегированного пользователя. |
||
16 | |||
17 | h2. Подключаемся к гипервизору |
||
18 | |||
19 | h3. Ищем сокет |
||
20 | |||
21 | host # *netstat -ax |grep 319.cont* |
||
22 | |||
23 | <pre> |
||
24 | unix 2 [ ACC ] STREAM LISTENING 8713 /run/qemu/qemu319.control.sock |
||
25 | </pre> |
||
26 | |||
27 | h3. Соединяемся в режиме monitor (-H) |
||
28 | |||
29 | host # *qmp-shell -H /run/qemu/qemu319.control.sock* |
||
30 | |||
31 | <pre> |
||
32 | Welcome to the HMP shell! |
||
33 | Connected to QEMU 1.4.2 |
||
34 | |||
35 | (QEMU) |
||
36 | </pre> |
||
37 | |||
38 | h2. Добавляем диск |
||
39 | |||
40 | h3. Смотрим текущие диски |
||
41 | |||
42 | (QEMU) *info block* |
||
43 | |||
44 | <pre> |
||
45 | disk-319-panda-root: removable=0 io-status=ok file=/dev/mapper/fc-kvm319-panda-root ro=0 drv=raw encrypted=0 bps=0 bps_rd=0 bps_wr=0 iops=0 iops_rd=0 iops_wr=0 |
||
46 | ide1-cd0: removable=1 locked=0 tray-open=0 io-status=ok [not inserted] |
||
47 | floppy0: removable=1 locked=0 tray-open=0 [not inserted] |
||
48 | sd0: removable=1 locked=0 tray-open=0 [not inserted] |
||
49 | </pre> |
||
50 | |||
51 | h3. Добавляем наш диск |
||
52 | |||
53 | 5 | Андрей Волков | (QEMU) *drive_add auto file=/dev/safespace/qemu319-panda-root,if=none,id=disk-root2,media=disk,cache=none,format=raw* |
54 | 1 | Андрей Волков | |
55 | <pre> |
||
56 | OK |
||
57 | </pre> |
||
58 | |||
59 | 2 | Андрей Волков | h3. Смотрим результат |
60 | |||
61 | 1 | Андрей Волков | (QEMU) *info block* |
62 | |||
63 | <pre> |
||
64 | disk-319-panda-root: removable=0 io-status=ok file=/dev/mapper/fc-kvm319-panda-root ro=0 drv=raw encrypted=0 bps=0 bps_rd=0 bps_wr=0 iops=0 iops_rd=0 iops_wr=0 |
||
65 | ide1-cd0: removable=1 locked=0 tray-open=0 io-status=ok [not inserted] |
||
66 | floppy0: removable=1 locked=0 tray-open=0 [not inserted] |
||
67 | sd0: removable=1 locked=0 tray-open=0 [not inserted] |
||
68 | disk-319-panda-root2: removable=1 locked=0 tray-open=0 file=/dev/safespace/qemu319-panda-root ro=0 drv=raw encrypted=0 bps=0 bps_rd=0 bps_wr=0 iops=0 iops_rd=0 iops_wr=0 |
||
69 | </pre> |
||
70 | 2 | Андрей Волков | |
71 | это пол дела |
||
72 | |||
73 | h2. Добавляем контроллер pci для нового диска |
||
74 | |||
75 | 3 | Андрей Волков | h3. Современный вариант |
76 | |||
77 | <pre> |
||
78 | 6 | Андрей Волков | device_add virtio-blk-pci,drive=disk-root2,id=pci-disk-root2 |
79 | 3 | Андрей Волков | </pre> |
80 | |||
81 | {{collapse(Старый вариант) |
||
82 | |||
83 | 2 | Андрей Волков | h3. Соединяемся в режиме QMP |
84 | |||
85 | host # *qmp-shell /run/qemu/qemu319.control.sock* |
||
86 | |||
87 | <pre> |
||
88 | Welcome to the QMP low-level shell! |
||
89 | Connected to QEMU 1.4.2 |
||
90 | |||
91 | (QEMU) |
||
92 | </pre> |
||
93 | |||
94 | h3. Добавляем контроллер |
||
95 | |||
96 | (QEMU) *device_add driver=virtio-blk-pci drive=disk-319-panda-root2* |
||
97 | |||
98 | <pre> |
||
99 | {u'return': {}} |
||
100 | </pre> |
||
101 | 3 | Андрей Волков | |
102 | }} |
||
103 | 2 | Андрей Волков | |
104 | Готово! |
||
105 | |||
106 | h2. Проверяем на госте |
||
107 | |||
108 | <pre> |
||
109 | pci 0000:00:05.0: [1af4:1001] type 00 class 0x010000 |
||
110 | pci 0000:00:05.0: reg 10: [io 0x0000-0x003f] |
||
111 | pci 0000:00:05.0: reg 14: [mem 0x00000000-0x00000fff] |
||
112 | pci 0000:00:05.0: BAR 1: assigned [mem 0x80000000-0x80000fff] |
||
113 | pci 0000:00:05.0: BAR 0: assigned [io 0x1000-0x103f] |
||
114 | pci 0000:00:00.0: no hotplug settings from platform |
||
115 | pci 0000:00:00.0: using default PCI settings |
||
116 | pci 0000:00:01.0: no hotplug settings from platform |
||
117 | pci 0000:00:01.0: using default PCI settings |
||
118 | pci 0000:00:01.1: no hotplug settings from platform |
||
119 | pci 0000:00:01.1: using default PCI settings |
||
120 | pci 0000:00:01.3: no hotplug settings from platform |
||
121 | pci 0000:00:01.3: using default PCI settings |
||
122 | pci 0000:00:02.0: no hotplug settings from platform |
||
123 | pci 0000:00:02.0: using default PCI settings |
||
124 | virtio-pci 0000:00:03.0: no hotplug settings from platform |
||
125 | virtio-pci 0000:00:03.0: using default PCI settings |
||
126 | virtio-pci 0000:00:04.0: no hotplug settings from platform |
||
127 | virtio-pci 0000:00:04.0: using default PCI settings |
||
128 | pci 0000:00:05.0: no hotplug settings from platform |
||
129 | pci 0000:00:05.0: using default PCI settings |
||
130 | virtio-pci 0000:00:05.0: enabling device (0000 -> 0003) |
||
131 | ACPI: PCI Interrupt Link [LNKA] enabled at IRQ 10 |
||
132 | virtio-pci 0000:00:05.0: setting latency timer to 64 |
||
133 | virtio-pci 0000:00:05.0: irq 45 for MSI/MSI-X |
||
134 | virtio-pci 0000:00:05.0: irq 46 for MSI/MSI-X |
||
135 | vdb: unknown partition table |
||
136 | </pre> |
||
137 | |||
138 | Это успех! |