function domain_get_xml($domain, $xpath = NULL) { $dom = $this->get_domain_object($domain); if (!$dom) return false; $tmp = libvirt_domain_get_xml_desc($dom, $xpath); return ($tmp) ? $tmp : $this->_set_last_error(); }
function domain_get_xml($domain, $get_inactive = false) { $dom = $this->get_domain_object($domain); if (!$dom) { return false; } $tmp = libvirt_domain_get_xml_desc($dom, $get_inactive ? VIR_DOMAIN_XML_INACTIVE : 0); return $tmp ? $tmp : $this->_set_last_error(); }
/** * fetch array of NIC information from a virtual machine on the virt host * * @global resource $host_conn libvirt connection * * @param string $vm_virt_id virt_id of the vm * * @return array vm nic info */ function ace_kvm_vm_get_nic_array($vm_virt_id) { global $host_conn; $nic_array = array(); $vm_res = libvirt_domain_lookup_by_name($host_conn, $vm_virt_id); ace_kvm_log_last_error(); $xml = libvirt_domain_get_xml_desc($vm_res, NULL); ace_kvm_log_last_error(); $vmXML = new SimpleXMLElement($xml); $arr_nics = $vmXML->xpath("//interface[@type='network']"); $c = count($arr_nics); for ($n = 0; $n < $c; $n++) { $nic_array[$n]['mac'] = (string) $arr_nics[$n]->mac->attributes()->address; $nic_array[$n]['network'] = (string) $arr_nics[$n]->source->attributes()->network; //$nic_array[ $n ]['model'] = (string)$arr_nics[ $n ]->model->attributes()->type; $nic_array[$n]['pxe_enable'] = (string) $arr_nics[$n]->rom->attributes()->bar; //$nic_array[ $n ]['host_interface'] = (string)$arr_nics[ $n ]->target->attributes()->dev; //$nic_array[ $n ]['alias'] = (string)$arr_nics[ $n ]->alias->attributes()->name; $nic_array[$n]['link_state'] = (string) $arr_nics[$n]->link->attributes()->state; } return $nic_array; }