Skip to content

Commit 4248a3a

Browse files
committed
Merge pull request xapi-project#415 from djs55/remove-blkback-workaround
[block]: remove physical-device workaround following linux-2.6.32.pq.hg ...
2 parents 703073c + b63b841 commit 4248a3a

File tree

5 files changed

+3
-79
lines changed

5 files changed

+3
-79
lines changed

ocaml/xapi/monitor.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
open Threadext
3636
open Stringext
3737
open Listext
38+
open Fun
3839
open Printf
3940
open Vmopshelpers
4041
open Monitor_types
@@ -365,7 +366,8 @@ let update_vbds doms =
365366
else
366367
Scanf.sscanf vbd "vbd-%d-%d" (fun id devid -> (id, devid))
367368
in
368-
let device_name = Device.Vbd.device_name devid in
369+
let open Device_number in
370+
let device_name = devid |> of_xenstore_key |> to_linux_device in
369371
let vbd_name = Printf.sprintf "vbd_%s" device_name in
370372
(* If blktap fails to cleanup then we might find a backend domid which doesn't
371373
correspond to an active domain uuid. Skip these for now. *)

ocaml/xenops/device.ml

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -279,55 +279,6 @@ let shutdown_mode_of_device ~xs (x: device) =
279279
then ShutdownRequest
280280
else Classic
281281

282-
let blkback_needs_physical_device_in_transaction ~xs (x: device) =
283-
read_feature_flag ~xs x "feature-blkback-needs-physical-device-in-transaction"
284-
285-
let major_number_table = [| 3; 22; 33; 34; 56; 57; 88; 89; 90; 91 |]
286-
287-
(** Given a string device name, return the major and minor number *)
288-
let device_major_minor name =
289-
(* This is the same algorithm xend uses: *)
290-
let a = int_of_char 'a' in
291-
(* Interpret as 'sda1', 'hda' etc *)
292-
try
293-
let number chars =
294-
if chars = [] then
295-
0
296-
else
297-
int_of_string (String.implode chars) in
298-
match String.explode name with
299-
| 's' :: 'd' :: ('a'..'p' as letter) :: rest ->
300-
8, 16 * (int_of_char letter - a) + (number rest)
301-
| 'x' :: 'v' :: 'd' :: ('a'..'p' as letter) :: rest ->
302-
202, 16 * (int_of_char letter - a) + (number rest)
303-
| 'h' :: 'd' :: ('a'..'t' as letter) :: rest ->
304-
let n = int_of_char letter - a in
305-
major_number_table.(n / 2), 64 * (n mod 2) + (number rest)
306-
| _ ->
307-
raise (Device_unrecognized name)
308-
with _ ->
309-
let file = if Filename.is_relative name then "/dev/" ^ name else name in
310-
Statdev.get_major_minor file
311-
312-
(** Given a major and minor number, return a device name *)
313-
let major_minor_to_device (major, minor) =
314-
let a = int_of_char 'a' in
315-
let number x = if x = 0 then "" else string_of_int x in
316-
match major with
317-
| 8 -> Printf.sprintf "sd%c%s" (char_of_int (minor / 16 + a)) (number (minor mod 16))
318-
| 202 -> Printf.sprintf "xvd%c%s" (char_of_int (minor / 16 + a)) (number (minor mod 16))
319-
| x ->
320-
(* Find the index of x in the table *)
321-
let n = snd(Array.fold_left (fun (idx, result) n -> idx + 1, if x = n then idx else result) (0, -1) major_number_table) in
322-
if n = -1 then failwith (Printf.sprintf "Couldn't determine device name for (%d, %d)" major minor)
323-
else
324-
let plus_one, minor = if minor >= 64 then 1, minor - 64 else 0, minor in
325-
Printf.sprintf "hd%c%s" (char_of_int (n * 2 + plus_one + a)) (number minor)
326-
327-
let device_name number =
328-
let major, minor = number / 256, number mod 256 in
329-
major_minor_to_device (major, minor)
330-
331282
type mode = ReadOnly | ReadWrite
332283

333284
let string_of_mode = function
@@ -378,10 +329,6 @@ let devty_of_string = function
378329
| "disk" -> Disk
379330
| _ -> invalid_arg "devty_of_string"
380331

381-
let string_of_major_minor file =
382-
let major, minor = device_major_minor file in
383-
sprintf "%x:%x" major minor
384-
385332
let kind_of_physty physty =
386333
match physty with
387334
| Qcow -> Tap
@@ -535,18 +482,10 @@ let add ~xs ~hvm ~mode ~device_number ~phystype ~params ~dev_type ~unpluggable
535482
"mode", string_of_mode mode;
536483
"params", params;
537484
];
538-
if blkback_needs_physical_device_in_transaction ~xs device then
539-
Hashtbl.add back_tbl "physical-device" (string_of_major_minor params);
540485

541486
if protocol <> Protocol_Native then
542487
Hashtbl.add front_tbl "protocol" (string_of_protocol protocol);
543488

544-
if hvm && dev_type = CDROM then
545-
(* CA-50383: Don't place physical-device in the HVM CDROM
546-
case, to prevent blkback from pinning the device node. A
547-
Vbd.media_eject will only make qemu close it again. *)
548-
Hashtbl.remove back_tbl "physical-device";
549-
550489
let back = Hashtbl.to_list back_tbl in
551490
let front = Hashtbl.to_list front_tbl in
552491

ocaml/xenops/device.mli

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ sig
4343
val string_of_devty : devty -> string
4444
val devty_of_string : string -> devty
4545

46-
val device_name : int -> string
47-
val device_major_minor : string -> int * int
48-
val major_minor_to_device : int * int -> string
49-
5046
val add : xs:Xenstore.Xs.xsh -> hvm:bool -> mode:mode
5147
-> device_number:Device_number.t
5248
-> phystype:physty -> params:string

ocaml/xenops/xenops.ml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -420,14 +420,6 @@ let affinity_get ~xc ~domid ~vcpu =
420420
Array.iteri (fun i b -> s.[i] <- if b then '1' else '0') cpumap;
421421
printf "%s\n" s
422422

423-
let self_test () =
424-
let device_tests = [ "sda2"; "sda"; "xvdd"; "xvda1"; "hde4"; "hdf" ] in
425-
let numbers = List.map Device.Vbd.device_major_minor device_tests in
426-
let names = List.map Device.Vbd.major_minor_to_device numbers in
427-
List.iter (fun (a, ((major, minor), b)) ->
428-
if a <> b then failwith (Printf.sprintf "%s -> (%d, %d) -> %s" a major minor b))
429-
(List.combine device_tests (List.combine numbers names))
430-
431423
let cmd_alias cmd =
432424
match cmd with
433425
| "init" -> "create_domain"
@@ -871,8 +863,6 @@ let _ = try
871863
with_xc (fun xc -> print_pcpus_info ~xc);
872864
| "capabilities" ->
873865
with_xc (fun xc -> print_endline (Xenctrl.version_capabilities xc))
874-
| "test" ->
875-
self_test ()
876866
| "help" ->
877867
raise (usage (try Some (List.hd otherargs) with _ -> None) allcommands)
878868
| s ->

scripts/init.d-xapi

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ start() {
3434
# This init.d script is only used on the XCP 'appliance' so we assume
3535
# we have the shutdown-request ability in the dom0 kernel
3636
xenstore-write /local/domain/0/control/feature-shutdown-request 1
37-
# we also know the dom0 kernel has a bug where it needs the physical-device
38-
# key to be created in the same transaction as the params key.
39-
xenstore-write /local/domain/0/control/feature-blkback-needs-physical-device-in-transaction 1
4037

4138
# clear out any old xapi coredumps
4239
rm -rf /var/xapi/debug

0 commit comments

Comments
 (0)