Ejemplo n.º 1
0
/* 
 * Shutdown hardware resources used by a VM.
 * The CPU must have been stopped.
 */
int vm_hardware_shutdown(vm_instance_t *vm)
{  
   int i;

   if ((vm->status == VM_STATUS_HALTED) || !vm->cpu_group) {
      vm_log(vm,"VM","trying to shutdown an inactive VM.\n");
      return(-1);
   }

   vm_log(vm,"VM","shutdown procedure engaged.\n");

   /* Mark the VM as halted */
   vm->status = VM_STATUS_HALTED;

   /* Free the object list */
   vm_object_free_list(vm);

   /* Free resources used by PCI busses */
   vm_log(vm,"VM","removing PCI busses.\n");
   pci_io_data_remove(vm,vm->pci_io_space);
   pci_bus_remove(vm->pci_bus[0]);
   pci_bus_remove(vm->pci_bus[1]);
   vm->pci_bus[0] = vm->pci_bus[1] = NULL;

   /* Free the PCI bus pool */
   for(i=0;i<VM_PCI_POOL_SIZE;i++) {
      if (vm->pci_bus_pool[i] != NULL) {
         pci_bus_remove(vm->pci_bus_pool[i]);
         vm->pci_bus_pool[i] = NULL;
      }
   }     

   /* Remove the IRQ routing vectors */
   vm->set_irq = NULL;
   vm->clear_irq = NULL;

   /* Delete the VTTY for Console and AUX ports */   
   vm_log(vm,"VM","deleting VTTY.\n");
   vm_delete_vtty(vm);

   /* Delete system CPU group */
   vm_log(vm,"VM","deleting system CPUs.\n");
   cpu_group_delete(vm->cpu_group);
   vm->cpu_group = NULL;
   vm->boot_cpu = NULL;

   vm_log(vm,"VM","shutdown procedure completed.\n");
   m_log("VM","VM %s shutdown.\n",vm->name);
   return(0);
}
Ejemplo n.º 2
0
static int pci_bus_remove_wrapper(struct device *dev)
{
    int r;
    struct pci_dev *pci_dev = to_pci_dev(dev);
    struct physdev_manage_pci manage_pci;
    manage_pci.bus = pci_dev->bus->number;
    manage_pci.devfn = pci_dev->devfn;

    r = pci_bus_remove(dev);
    /* dev and pci_dev are no longer valid!! */

#ifndef __ia64__
    WARN_ON(HYPERVISOR_physdev_op(PHYSDEVOP_manage_pci_remove,
                                  &manage_pci));
#endif
    return r;
}