Revision 5397e0b7

b/lib/cmdlib.py
3054 3054
    # set optional parameters to none if they don't exist
3055 3055
    for attr in ["kernel_path", "initrd_path", "hvm_boot_order", "pnode",
3056 3056
                 "iallocator", "hvm_acpi", "hvm_pae", "hvm_cdrom_image_path",
3057
                 "vnc_bind_address"]:
3057
                 "hvm_nic_type", "hvm_disk_type", "vnc_bind_address"]:
3058 3058
      if not hasattr(self.op, attr):
3059 3059
        setattr(self.op, attr, None)
3060 3060

  
......
3269 3269
                                   " like a valid IP address" %
3270 3270
                                   self.op.vnc_bind_address)
3271 3271

  
3272
    # Xen HVM device type checks
3273
    if self.sstore.GetHypervisorType() == constants.HT_XEN_HVM31:
3274
      if self.op.hvm_nic_type not in constants.HT_HVM_VALID_NIC_TYPES:
3275
        raise errors.OpPrereqError("Invalid NIC type %s specified for Xen HVM"
3276
                                   " hypervisor" % self.op.hvm_nic_type)
3277
      if self.op.hvm_disk_type not in constants.HT_HVM_VALID_DISK_TYPES:
3278
        raise errors.OpPrereqError("Invalid disk type %s specified for Xen HVM"
3279
                                   " hypervisor" % self.op.hvm_disk_type)
3280

  
3272 3281
    if self.op.start:
3273 3282
      self.instance_status = 'up'
3274 3283
    else:
......
3334 3343
                            hvm_pae=self.op.hvm_pae,
3335 3344
                            hvm_cdrom_image_path=self.op.hvm_cdrom_image_path,
3336 3345
                            vnc_bind_address=self.op.vnc_bind_address,
3346
                            hvm_nic_type=self.op.hvm_nic_type,
3347
                            hvm_disk_type=self.op.hvm_disk_type,
3337 3348
                            )
3338 3349

  
3339 3350
    feedback_fn("* creating instance disks...")
......
4132 4143
        idict["hvm_acpi"] = instance.hvm_acpi
4133 4144
        idict["hvm_pae"] = instance.hvm_pae
4134 4145
        idict["hvm_cdrom_image_path"] = instance.hvm_cdrom_image_path
4146
        idict["hvm_nic_type"] = instance.hvm_nic_type
4147
        idict["hvm_disk_type"] = instance.hvm_disk_type
4135 4148

  
4136 4149
      if htkind in constants.HTS_REQ_PORT:
4137 4150
        idict["vnc_bind_address"] = instance.vnc_bind_address
......
4203 4216
    self.hvm_boot_order = getattr(self.op, "hvm_boot_order", None)
4204 4217
    self.hvm_acpi = getattr(self.op, "hvm_acpi", None)
4205 4218
    self.hvm_pae = getattr(self.op, "hvm_pae", None)
4219
    self.hvm_nic_type = getattr(self.op, "hvm_nic_type", None)
4220
    self.hvm_disk_type = getattr(self.op, "hvm_disk_type", None)
4206 4221
    self.hvm_cdrom_image_path = getattr(self.op, "hvm_cdrom_image_path", None)
4207 4222
    self.vnc_bind_address = getattr(self.op, "vnc_bind_address", None)
4208 4223
    all_parms = [self.mem, self.vcpus, self.ip, self.bridge, self.mac,
4209 4224
                 self.kernel_path, self.initrd_path, self.hvm_boot_order,
4210 4225
                 self.hvm_acpi, self.hvm_pae, self.hvm_cdrom_image_path,
4211
                 self.vnc_bind_address]
4226
                 self.vnc_bind_address, self.hvm_nic_type, self.hvm_disk_type]
4212 4227
    if all_parms.count(None) == len(all_parms):
4213 4228
      raise errors.OpPrereqError("No changes submitted")
4214 4229
    if self.mem is not None:
......
4334 4349
    if self.hvm_pae is not None:
4335 4350
      instance.hvm_pae = self.hvm_pae
4336 4351
      result.append(("hvm_pae", self.hvm_pae))
4352
    if self.hvm_nic_type is not None:
4353
      instance.hvm_nic_type = self.hvm_nic_type
4354
      result.append(("hvm_nic_type", self.hvm_nic_type))
4355
    if self.hvm_disk_type is not None:
4356
      instance.hvm_disk_type = self.hvm_disk_type
4357
      result.append(("hvm_disk_type", self.hvm_disk_type))
4337 4358
    if self.hvm_cdrom_image_path:
4338 4359
      if self.hvm_cdrom_image_path == constants.VALUE_NONE:
4339 4360
        instance.hvm_cdrom_image_path = None
b/lib/constants.py
262 262
HT_HVM_NIC_NE2K_ISA = "ne2k_isa"
263 263
HT_HVM_DEV_PARAVIRTUAL = "paravirtual"
264 264
HT_HVM_DEV_IOEMU = "ioemu"
265
HT_HVM_VALID_NIC_TYPES = frozenset([HT_HVM_NIC_RTL8139, HT_HVM_NIC_NE2K_PCI,
266
                                    HT_HVM_NIC_NE2K_ISA,
267
                                    HT_HVM_DEV_PARAVIRTUAL])
268
HT_HVM_VALID_DISK_TYPES = frozenset([HT_HVM_DEV_PARAVIRTUAL, HT_HVM_DEV_IOEMU])
265 269

  
266 270
# Cluster Verify steps
267 271
VERIFY_NPLUSONE_MEM = 'nplusone_mem'
b/lib/hypervisor/hv_xen.py
431 431

  
432 432
    vif_data = []
433 433
    for nic in instance.nics:
434
      nic_str = "mac=%s, bridge=%s, type=ioemu" % (nic.mac, nic.bridge)
434
      if instance.hvm_nic_type is None: # ensure old instances don't change
435
        nic_type = ", type=ioemu"
436
      elif instance.hvm_nic_type == constants.HT_HVM_DEV_PARAVIRTUAL:
437
        nic_type = ", type=paravirtualized"
438
      else:
439
        nic_type = ", model=%s, type=ioemu" % instance.hvm_nic_type
440

  
441
      nic_str = "mac=%s, bridge=%s%s" % (nic.mac, nic.bridge, nic_type)
435 442
      ip = getattr(nic, "ip", None)
436 443
      if ip is not None:
437 444
        nic_str += ", ip=%s" % ip
......
440 447
    config.write("vif = [%s]\n" % ",".join(vif_data))
441 448
    disk_data = cls._GetConfigFileDiskData(instance.disk_template,
442 449
                                            block_devices)
443
    disk_data = [line.replace(",sd", ",ioemu:hd") for line in disk_data]
450
    if ((instance.hvm_disk_type is None) or
451
        (instance.hvm_disk_type == constants.HT_HVM_DEV_IOEMU)):
452
      replacement = ",ioemu:hd"
453
    else:
454
      replacement = ",hd"
455
    disk_data = [line.replace(",sd", replacement) for line in disk_data]
444 456
    if instance.hvm_cdrom_image_path is not None:
445 457
      iso = "'file:%s,hdc:cdrom,r'" % (instance.hvm_cdrom_image_path)
446 458
      disk_data.append(iso)
b/lib/opcodes.py
310 310
    "kernel_path", "initrd_path", "hvm_boot_order", "hvm_acpi",
311 311
    "hvm_pae", "hvm_cdrom_image_path", "vnc_bind_address",
312 312
    "file_storage_dir", "file_driver",
313
    "iallocator",
313
    "iallocator", "hvm_nic_type", "hvm_disk_type",
314 314
    ]
315 315

  
316 316

  
......
399 399
  __slots__ = [
400 400
    "instance_name", "mem", "vcpus", "ip", "bridge", "mac",
401 401
    "kernel_path", "initrd_path", "hvm_boot_order", "hvm_acpi",
402
    "hvm_pae", "hvm_cdrom_image_path", "vnc_bind_address"
402
    "hvm_pae", "hvm_cdrom_image_path", "vnc_bind_address",
403
    "hvm_nic_type", "hvm_disk_type"
403 404
    ]
404 405

  
405 406

  

Also available in: Unified diff