Hi all,
i created a script in PHP for create a virtual server with two QCOW2 discs …
one is our system for installation and second is target system.
After successfully instalation (create a blank Debian system, prepare all files
and grub partitions) i need a restart virtual without a installation disk.
If i use Virsh:
detach-disk --domain debian-test2 --persistent --target vda
reset debian-test2
everything works well.
If i use a PHP, there is „complicated“ way and „simple“ way:
1, complicated:
libvirt_domain_destroy($domain);
libvirt_domain_undefine($domain);
$xml = domain_create_xml($name,$uuid,$memory,$cpu,$vnc,$mac);
$domain = libvirt_domain_define_xml($server->conn, $xml);
libvirt_domain_disk_add($domain, "/users/".$name.".img", "vdb", "virtio",
"qcow2", NULL);
libvirt_domain_create($domain);
(or instead libvirt_domain_disk_add i can define disk directly in XML)
But in this case, the server will not boot (GRUB error)
2, simple:
libvirt_domain_disk_remove($domain,“vda“);
libvirt_domain_reboot($domain);
The problem of this solution is thats not working. The remove disk is failing
with error „Unable attach disk“ - i looks to source code, and yes, there is a
mystake with „attach“/„detach“, but main problem i see in log from libvirt:
Aug 1 02:57:05 ry libvirtd[19051]: missing source information for device vda
I try to put source detail to xml in source of PHP module
libvirt-domain.c:
822 if (asprintf(&newXml,
823 " <disk type='file' device='disk'>\n"
824 " <target dev='%s'/>\n"
825 " </disk>", dev) < 0) {
826 set_error("Out of memory" TSRMLS_CC);
827 goto error;
828 }
but my attempts was unsuccesfull (i’m not C programmer).
Questions:
A, why complicated way is not working and system dont want boot (GRUB error) if
virsh works fine
B, why libvirt_domain_disk_remove is not work ? I use libvirt and libvirt-php
latest from git.
Thank you,
Jan
_______________________________________________
libvirt-users mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/libvirt-users