function domain_nic_add($domain, $mac, $network, $model = false)
 {
     $dom = $this->get_domain_object($domain);
     if ($model == 'default') {
         $model = false;
     }
     $tmp = libvirt_domain_nic_add($dom, $mac, $network, $model);
     return $tmp ? $tmp : $this->_set_last_error();
 }
Пример #2
0
/**
 * attach NIC device to a virtual machine on the virt host
 *
 * @todo FIX THIS, so we can use it instead of VIRSH
 *
 * @global  resource $host_conn          libvirt connection
 *
 * @param   string   $vm_virt_id         virt_id of the vm
 * @param   string   $vm_nic_mac_address mac address of NIC
 *
 * @return  bool                on success
 */
function ace_kvm_vm_attach_nic($vm_virt_id, $vm_nic_mac_address)
{
    # PCIe address slot number clash? see the working virsh version above
    global $host_conn;
    $vm_res = libvirt_domain_lookup_by_name($host_conn, $vm_virt_id);
    ace_kvm_log_last_error();
    $flags = libvirt_domain_is_active($vm_res) ? 3 : 2;
    ace_kvm_log_last_error();
    $new_vm_res = libvirt_domain_nic_add($vm_res, $vm_nic_mac_address, _DISCONNECTED_VIRT_NETWORK_ID_, 'virtio', $flags);
    ace_kvm_log_last_error();
    return is_resource($new_vm_res) ? TRUE : FALSE;
}