~ubuntu-branches/ubuntu/quantal/virtinst/quantal-proposed

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
#
# List of OS Specific data
#
# Copyright 2006-2008  Red Hat, Inc.
# Jeremy Katz <katzj@redhat.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free  Software Foundation; either version 2 of the License, or
# (at your option)  any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301 USA.

import support
from VirtualDevice import VirtualDevice
from virtinst import _gettext as _

HV_ALL = "all"

"""
Default values for OS_TYPES keys. Can be overwritten at os_type or
variant level
"""

NET   = VirtualDevice.VIRTUAL_DEV_NET
DISK  = VirtualDevice.VIRTUAL_DEV_DISK
INPUT = VirtualDevice.VIRTUAL_DEV_INPUT
SOUND = VirtualDevice.VIRTUAL_DEV_AUDIO
VIDEO = VirtualDevice.VIRTUAL_DEV_VIDEO

VIRTIO_DISK = {
    "bus" : [
        (support.SUPPORT_CONN_HV_VIRTIO, "virtio"),
    ]
}

VIRTIO_NET = {
    "model" : [
        (support.SUPPORT_CONN_HV_VIRTIO, "virtio"),
    ]
}

USB_TABLET = {
    "type" : [
        (HV_ALL, "tablet"),
    ],
    "bus"  : [
        (HV_ALL, "usb"),
    ]
}

VGA_VIDEO = {
    "model_type": [
        (HV_ALL, "vga"),
    ]
}

DEFAULTS = {
    "acpi":             True,
    "apic":             True,
    "clock":            "utc",
    "continue":         False,
    "distro":           None,
    "label":            None,
    "pv_cdrom_install": False,
    "supported":        False,

    "devices" : {
        #  "devname" : { "attribute" : [( ["applicable", "hv-type", list"],
        #                               "recommended value for hv-types" ),]},
        INPUT   : {
            "type" : [
                (HV_ALL, "mouse")
            ],
            "bus"  : [
                (HV_ALL, "ps2")
            ],
        },

        DISK    : {
            "bus"  : [
                (HV_ALL, None)
            ],
        },

        NET     : {
            "model": [
                (HV_ALL, None)
            ],
        },

        SOUND : {
            "model": [
                (support.SUPPORT_CONN_HV_SOUND_ICH6, "ich6"),
                (support.SUPPORT_CONN_HV_SOUND_AC97, "ac97"),
                (HV_ALL, "es1370"),
            ]
        },

        VIDEO : {
            "model_type": [
                (HV_ALL, "cirrus"),
            ]
        },
    }
}

def sort_helper(tosort, sortpref=None):
    """
    Helps properly sorting os dictionary entires
    """
    sortby_mappings = {}
    distro_mappings = {}
    retlist = []
    sortpref = sortpref or []

    # Make sure we are sorting by 'sortby' if specified, and group distros
    # by their 'distro' tag first and foremost
    for key, osinfo in tosort.items():
        if osinfo.get("skip"):
            continue

        sortby = osinfo.get("sortby")
        if not sortby:
            sortby = key
        sortby_mappings[sortby] = key

        distro = osinfo.get("distro") or "zzzzzzz"
        if distro not in distro_mappings:
            distro_mappings[distro] = []
        distro_mappings[distro].append(sortby)

    # We want returned lists to be sorted descending by 'distro', so we get
    # debian5, debian4, fedora14, fedora13
    #   rather than
    # debian4, debian5, fedora13, fedora14
    for distro_list in distro_mappings.values():
        distro_list.sort()
        distro_list.reverse()

    sorted_distro_list = distro_mappings.keys()
    sorted_distro_list.sort()
    sortpref.reverse()
    for prefer in sortpref:
        if not prefer in sorted_distro_list:
            continue
        sorted_distro_list.remove(prefer)
        sorted_distro_list.insert(0, prefer)

    for distro in sorted_distro_list:
        distro_list = distro_mappings[distro]
        for key in distro_list:
            orig_key = sortby_mappings[key]
            retlist.append(orig_key)

    return retlist

def parse_key_entry(conn, hv_type, key_entry, defaults):
    ret = None
    found = False
    if type(key_entry) == list:

        # List of tuples with (support -> value) mappings
        for tup in key_entry:

            support_key = tup[0]
            value = tup[1]

            # HV_ALL means don't check for support, just return the value
            if support_key != HV_ALL:
                support_ret = support.check_conn_hv_support(conn,
                                                            support_key,
                                                            hv_type)

                if support_ret != True:
                    continue

            found = True
            ret = value
            break
    else:
        found = True
        ret = key_entry

    if not found and defaults:
        ret = parse_key_entry(conn, hv_type, defaults, None)

    return ret

def lookup_osdict_key(conn, hv_type, os_type, var, key):

    defaults = DEFAULTS[key]
    dictval = defaults
    if os_type:
        if var and key in OS_TYPES[os_type]["variants"][var]:
            dictval = OS_TYPES[os_type]["variants"][var][key]
        elif key in OS_TYPES[os_type]:
            dictval = OS_TYPES[os_type][key]

    return parse_key_entry(conn, hv_type, dictval, defaults)


def lookup_device_param(conn, hv_type, os_type, var, device_key, param):

    os_devs = lookup_osdict_key(conn, hv_type, os_type, var, "devices")
    defaults = DEFAULTS["devices"]

    for devs in [os_devs, defaults]:
        if device_key not in devs:
            continue

        return parse_key_entry(conn, hv_type, devs[device_key][param],
                               defaults.get(param))

    raise RuntimeError(_("Invalid dictionary entry for device '%s %s'" %
                       (device_key, param)))


# NOTE: keep variant keys using only lowercase so we can do case
#       insensitive checks on user passed input
OS_TYPES = {
"linux": {
    "label": "Linux",
    "variants": {

    "rhel2.1": {
        "label": "Red Hat Enterprise Linux 2.1",
        "distro": "rhel"
    },
    "rhel3": {
        "label": "Red Hat Enterprise Linux 3",
        "distro": "rhel"
    },
    "rhel4": {
        "label": "Red Hat Enterprise Linux 4",
        "distro": "rhel",
        "supported": True,
    },
    "rhel5": {
        "label": "Red Hat Enterprise Linux 5",
        "distro": "rhel",
    },
    "rhel5.4": {
        "label": "Red Hat Enterprise Linux 5.4 or later",
        "distro": "rhel",
        "supported": True,
        "devices" : {
            DISK : VIRTIO_DISK,
            NET  : VIRTIO_NET,
        },
    },
    "rhel6": {
        "label": "Red Hat Enterprise Linux 6",
        "distro": "rhel",
        "supported": True,
        "devices" : {
            DISK : VIRTIO_DISK,
            NET  : VIRTIO_NET,
            INPUT: USB_TABLET,
        }
    },
    "rhel7": {
        "label": "Red Hat Enterprise Linux 7",
        "distro": "rhel",
        "supported": False,
        "devices" : {
            DISK : VIRTIO_DISK,
            NET  : VIRTIO_NET,
            INPUT: USB_TABLET,
        }
    },

    "fedora5": {
        "sortby": "fedora05",
        "label": "Fedora Core 5",
        "distro": "fedora"
    },
    "fedora6": {
        "sortby": "fedora06",
        "label": "Fedora Core 6",
        "distro": "fedora"
    },
    "fedora7": {
        "sortby": "fedora07",
        "label": "Fedora 7",
        "distro": "fedora"
    },
    "fedora8": {
        "sortby": "fedora08",
        "label": "Fedora 8",
        "distro": "fedora"
    },
    "fedora9": {
        "sortby":  "fedora09",
        "label": "Fedora 9",
        "distro": "fedora",
        "devices" : {
            # Apparently F9 has selinux errors when installing with virtio:
            # https://bugzilla.redhat.com/show_bug.cgi?id=470386
            #DISK : VIRTIO_DISK,
            NET  : VIRTIO_NET,
        }
    },
    "fedora10": {
        "label": "Fedora 10",
        "distro": "fedora",
        "devices" : {
            DISK : VIRTIO_DISK,
            NET  : VIRTIO_NET,
        }
    },
    "fedora11": {
        "label": "Fedora 11",
        "distro": "fedora",
        "devices" : {
            DISK : VIRTIO_DISK,
            NET  : VIRTIO_NET,
            INPUT: USB_TABLET,
        }
    },
    "fedora12": {
        "label": "Fedora 12",
        "distro": "fedora",
        "devices" : {
            DISK : VIRTIO_DISK,
            NET  : VIRTIO_NET,
            INPUT: USB_TABLET,
        }
    },
    "fedora13": {
        "label": "Fedora 13", "distro": "fedora",
        "devices" : {
            DISK : VIRTIO_DISK,
            NET  : VIRTIO_NET,
            INPUT: USB_TABLET,
        }
    },
    "fedora14": {
        "label": "Fedora 14",
        "distro": "fedora",
        "devices" : {
            DISK : VIRTIO_DISK,
            NET  : VIRTIO_NET,
            INPUT: USB_TABLET,
        }
    },
    "fedora15": {
        "label": "Fedora 15",
        "distro": "fedora",
        "supported": True,
        "devices" : {
            DISK : VIRTIO_DISK,
            NET  : VIRTIO_NET,
            INPUT: USB_TABLET,
        }
    },
    "fedora16": {
        "label": "Fedora 16",
        "distro": "fedora",
        "supported": True,
        "devices" : {
            DISK : VIRTIO_DISK,
            NET  : VIRTIO_NET,
            INPUT: USB_TABLET,
        }
    },
    "fedora17": {
        "label": "Fedora 17",
        "distro": "fedora",
        "supported": True,
        "devices" : {
            DISK : VIRTIO_DISK,
            NET  : VIRTIO_NET,
            INPUT: USB_TABLET,
        }
    },

    "opensuse11": {
        "label": "openSuse 11",
        "distro": "suse",
        "supported": True,
        "devices" : {
            DISK : VIRTIO_DISK,
            NET  : VIRTIO_NET,
        },
    },
    "opensuse12": {
        "label": "openSuse 12",
        "distro": "suse",
        "supported": True,
        "devices" : {
            DISK : VIRTIO_DISK,
            NET  : VIRTIO_NET,
        },
    },

    "sles10": {
        "label": "Suse Linux Enterprise Server",
        "distro": "suse",
        "supported": True,
    },
    "sles11": {
        "label": "Suse Linux Enterprise Server 11",
        "distro": "suse",
        "supported": True,
        "devices" : {
            DISK : VIRTIO_DISK,
            NET  : VIRTIO_NET,
        },
    },

    "mandriva2009": {
        "label": "Mandriva Linux 2009 and earlier",
        "distro": "mandriva"
    },
    "mandriva2010": {
        "label": "Mandriva Linux 2010 and later",
        "distro": "mandriva",
        "devices" : {
            DISK : VIRTIO_DISK,
            NET  : VIRTIO_NET,
        },
    },

    "mes5": {
        "label": "Mandriva Enterprise Server 5.0",
        "distro": "mandriva",
    },
    "mes5.1": {
        "label": "Mandriva Enterprise Server 5.1 and later",
        "distro": "mandriva",
        "supported": True,
        "devices" : {
            DISK : VIRTIO_DISK,
            NET  : VIRTIO_NET,
        },
    },

    "mageia1": {
        "label": "Mageia 1 and later",
        "distro": "mageia",
        "supported": True,
        "devices" : {
            DISK : VIRTIO_DISK,
            NET  : VIRTIO_NET,
            INPUT: USB_TABLET,
        },
    },


    "debianetch": {
        "label": "Debian Etch",
        "distro": "debian",
        "sortby": "debian4",
    },
    "debianlenny": {
        "label": "Debian Lenny",
        "distro": "debian",
        "sortby": "debian5",
        "supported": True,
        "devices" : {
            DISK : VIRTIO_DISK,
            NET  : VIRTIO_NET,
        },
    },
    "debiansqueeze": {
        "label": "Debian Squeeze",
        "distro": "debian",
        "sortby": "debian6",
        "supported": True,
        "devices" : {
            DISK : VIRTIO_DISK,
            NET  : VIRTIO_NET,
            INPUT: USB_TABLET,
        }
    },
    "debianwheezy": {
        "label": "Debian Wheezy",
        "distro": "debian",
        "sortby": "debian7",
        "supported": True,
        "devices" : {
                   DISK : VIRTIO_DISK,
                   NET  : VIRTIO_NET,
                   INPUT: USB_TABLET,
        }
    },

    "ubuntuhardy": {
        "label": "Ubuntu 8.04 LTS (Hardy Heron)",
        "distro": "ubuntu",
        "supported": True,
        "devices" : {
            NET  : VIRTIO_NET,
        },
    },
    "ubuntuintrepid": {
        "label": "Ubuntu 8.10 (Intrepid Ibex)",
        "distro": "ubuntu",
        "devices" : {
            NET  : VIRTIO_NET,
        },
    },
    "ubuntujaunty": {
        "label": "Ubuntu 9.04 (Jaunty Jackalope)",
        "distro": "ubuntu",
        "devices" : {
            DISK : VIRTIO_DISK,
            NET  : VIRTIO_NET,
        },
    },
    "ubuntukarmic": {
        "label": "Ubuntu 9.10 (Karmic Koala)",
        "distro": "ubuntu",
        "devices" : {
            DISK : VIRTIO_DISK,
            NET  : VIRTIO_NET,
        },
    },
    "ubuntulucid": {
        "label": "Ubuntu 10.04 LTS (Lucid Lynx)",
        "distro": "ubuntu",
        "supported": True,
        "devices" : {
            DISK : VIRTIO_DISK,
            NET  : VIRTIO_NET,
        },
    },
    "ubuntumaverick": {
        "label": "Ubuntu 10.10 (Maverick Meerkat)",
        "distro": "ubuntu",
        "devices" : {
            DISK : VIRTIO_DISK,
            NET  : VIRTIO_NET,
        },
    },
    "ubuntunatty": {
        "label": "Ubuntu 11.04 (Natty Narwhal)",
        "distro": "ubuntu",
        "supported": True,
        "devices" : {
            DISK : VIRTIO_DISK,
            NET  : VIRTIO_NET,
        },
    },
    "ubuntuoneiric": {
        "label": "Ubuntu 11.10 (Oneiric Ocelot)",
        "distro": "ubuntu",
        "supported": True,
        "devices" : {
            DISK : VIRTIO_DISK,
            NET  : VIRTIO_NET,
        },
    },
    "ubuntuprecise": {
        "label": "Ubuntu 12.04 LTS (Precise Pangolin)",
        "distro": "ubuntu",
        "supported": True,
        "devices" : {
            DISK : VIRTIO_DISK,
            NET  : VIRTIO_NET,
        },
    },
    "ubuntuquantal": {
        "label": "Ubuntu 12.10 (Quantal Quetzal)",
        "distro": "ubuntu",
        "supported": True,
        "devices" : {
            DISK : VIRTIO_DISK,
            NET  : VIRTIO_NET,
        },
    },

    "generic24": {
        "label": "Generic 2.4.x kernel"
    },
    "generic26": {
        "label": "Generic 2.6.x kernel"
    },
    "virtio26": {
        "sortby": "genericvirtio26",
        "label": "Generic 2.6.25 or later kernel with virtio",
        "devices" : {
            DISK : VIRTIO_DISK,
            NET  : VIRTIO_NET,
        },
    },

    },
},

"windows": {
    "label": "Windows",
    "clock": "localtime",
    "continue": True,
    "devices" : {
        INPUT : USB_TABLET,
        VIDEO : VGA_VIDEO,
    },

    "variants": {

    "winxp": {
        "label": "Microsoft Windows XP",
        "sortby": "mswin5",
        "distro" : "win",
        "supported": True,
        "acpi": [(support.SUPPORT_CONN_HV_SKIP_DEFAULT_ACPI, False)],
        "apic": [(support.SUPPORT_CONN_HV_SKIP_DEFAULT_ACPI, False)],
    },
    "winxp64": {
        "label": "Microsoft Windows XP (x86_64)",
        "supported": True,
        "sortby": "mswin564",
        "distro": "win",
    },
    "win2k": {
        "label": "Microsoft Windows 2000",
        "sortby" : "mswin4",
        "distro": "win",
        "acpi": [(support.SUPPORT_CONN_HV_SKIP_DEFAULT_ACPI, False)],
        "apic": [(support.SUPPORT_CONN_HV_SKIP_DEFAULT_ACPI, False)],
    },
    "win2k3": {
        "label": "Microsoft Windows Server 2003",
        "supported": True,
        "sortby" : "mswinserv2003",
        "distro": "winserv",
    },
    "win2k8": {
        "label": "Microsoft Windows Server 2008",
        "supported": True,
        "sortby": "mswinserv2008",
        "distro": "winserv",
    },
    "vista": {
        "label": "Microsoft Windows Vista",
        "supported": True,
        "sortby": "mswin6",
        "distro": "win",
    },
    "win7": {
        "label": "Microsoft Windows 7",
        "supported": True,
        "sortby": "mswin7",
        "distro": "win",
    },

    },
},

"solaris": {
    "label": "Solaris",
    "clock": "localtime",
    "pv_cdrom_install": True,
    "variants": {

    "solaris9": {
        "label": "Sun Solaris 9",
    },
    "solaris10": {
        "label": "Sun Solaris 10",
        "devices" : {
            INPUT : USB_TABLET,
        },
    },
    "opensolaris": {
        "label": "Sun OpenSolaris",
        "devices" : {
            INPUT : USB_TABLET,
        },
    },

    },
},

"unix": {
    "label": "UNIX",
    "variants": {

    "freebsd6": {
        "label": "FreeBSD 6.x" ,
        # http://www.nabble.com/Re%3A-Qemu%3A-bridging-on-FreeBSD-7.0-STABLE-p15919603.html
        "devices" : {
            NET : { "model" : [ (HV_ALL, "ne2k_pci") ] }
        },
    },
    "freebsd7": {
        "label": "FreeBSD 7.x" ,
        "devices" : {
            NET : { "model" : [ (HV_ALL, "ne2k_pci") ] }
        },
    },
    "freebsd8": {
        "label": "FreeBSD 8.x" ,
        "supported": True,
        "devices" : {
            NET : { "model" : [ (HV_ALL, "e1000") ] }
        },
    },

    "openbsd4": {
        "label": "OpenBSD 4.x" ,
        # http://calamari.reverse-dns.net:980/cgi-bin/moin.cgi/OpenbsdOnQemu
        # https://www.redhat.com/archives/et-mgmt-tools/2008-June/msg00018.html
        "devices" : {
            NET  : { "model" : [ (HV_ALL, "pcnet") ] }
        },
    },

    },
},

"other": {
    "label": "Other",
    "variants": {

    "msdos": {
        "label": "MS-DOS",
        "acpi": False,
        "apic": False,
    },

    "netware4": {
        "label": "Novell Netware 4",
    },
    "netware5": {
        "label": "Novell Netware 5",
    },
    "netware6": {
        "label": "Novell Netware 6",
        "pv_cdrom_install": True,
    },

    "generic": {
        "supported": True,
        "label": "Generic"
    },

    },
}
}

# Back compatibility entries
solaris_compat = OS_TYPES["unix"]["variants"]

solaris_compat["solaris9"] = OS_TYPES["solaris"]["variants"]["solaris9"].copy()
solaris_compat["solaris9"]["skip"] = True

solaris_compat["solaris10"] = OS_TYPES["solaris"]["variants"]["solaris10"].copy()
solaris_compat["solaris10"]["skip"] = True