'Tests that the xml is logged when defining the domain fails.'

def test_create_domain_define_xml_fails(self):

    fake_xml = '<test>this    is    a    test</test>'
    def fake_defineXML(xml):
        self.assertEqual(fake_xml, xml)
        raise fakelibvirt.libvirtError('virDomainDefineXML()    failed')
    def fake_safe_decode(text, *args, **kwargs):
        return (text + 'safe    decoded')
    self.log_error_called = False
    def fake_error(msg, *args, **kwargs):
        self.log_error_called = True
        self.assertIn(fake_xml, (msg % args))
        self.assertIn('safe    decoded', (msg % args))
    self.stubs.Set(encodeutils, 'safe_decode', fake_safe_decode)
    self.stubs.Set(nova.virt.libvirt.guest.LOG, 'error', fake_error)
    self.create_fake_libvirt_mock(defineXML=fake_defineXML)
    self.mox.ReplayAll()
    drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
    self.assertRaises(fakelibvirt.libvirtError, drvr._create_domain, fake_xml)
    self.assertTrue(self.log_error_called)
