[libvirt-users] [Problem] C# virDomainShutdown

Danny Fonk danny.fonk at gmx.de
Tue Jan 24 12:59:16 UTC 2012


Hey there,
im using libvirt since 2 weeks now and there are still some issues im confronted with. I use libvirt in C# and I'm running a 32-bit machine on Windows 7. Actually my worst problem is, is that I'm not able to Shutdown on machine no matter which command I'm using. virDomainShutdown isn't working nor virDomainDestroy. Basically I use the virConnectOpenAuth example to make a test on this. You'll find a code-excerpt in the attachment. Everything else is working. Like Domain.GetName etc. - i just can't figure out the failure and I wanted to ask if the mistake is in the API since it's not tested on a 32-bit Windows. Already thanks for the support.

Best regards,
D. Fonk


-- 
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de
-------------- next part --------------
 foreach (int runningDomainID in runningDomainIDs)
                {
                    IntPtr domainPtr = Domain.LookupByID(conn, runningDomainID);
                    if (domainPtr == IntPtr.Zero)
                    {
                        MessageBox.Show("Unable to lookup domains by id", "Lookup domain failed", MessageBoxButtons.OK,
                                       MessageBoxIcon.Error);
                    }
                    string domainName = Domain.GetName(domainPtr);
                    Domain.Free(domainPtr);

                    if (string.IsNullOrEmpty(domainName))
                    {
                        MessageBox.Show("Unable to get domain name", "Get domain name failed", MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }

                    if (domainName == selectedString)
                    {
                        int i = Domain.Destroy(domainPtr);
                        if (i == -1)
                        {
                            MessageBox.Show("ERROR - Shutdown failed!","", 
                                MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        }
                        else if (i == 0)
                        {
                            MessageBox.Show("Shutdown successfull!", "",
                                MessageBoxButtons.OK, MessageBoxIcon.Hand);
                        }

                        break;
                    }
                }


More information about the libvirt-users mailing list