Commit b9fdcb1e authored by Michal Novotny's avatar Michal Novotny

Fix x86_64 issues

Signed-off-by: 's avatarMichal Novotny <minovotn@redhat.com>
parent 089040dc
......@@ -8,10 +8,10 @@ EXTRA_DIST = libvirt-php.c sockets.c vncfunc.c libvirt-php.h
all-am: build clean-temp
build:
$(CC) $(CFLAGS) -fpic -DCOMPILE_DL_LIBVIRT=1 $(PHPINC) -c -o libvirt-php.o libvirt-php.c $(LIBXML_CFLAGS) $(DEFINES)
$(CC) $(CFLAGS) -fpic -DCOMPILE_DL_LIBVIRT=1 -c -o vncfunc.o vncfunc.c $(PHPINC) $(LIBXML_CFLAGS) $(DEFINES)
$(CC) $(CFLAGS) -fpic -DCOMPILE_DL_LIBVIRT=1 -c -o sockets.o sockets.c $(PHPINC) $(LIBXML_CFLAGS) $(DEFINES)
$(CC) $(CFLAGS) -shared $(LIBS) -rdynamic -o $(PACKAGE).so vncfunc.o sockets.o libvirt-php.o -ldl -lvirt $(LIBXML_LIBS)
$(CC) $(CFLAGS) -Wall -fpic -DCOMPILE_DL_LIBVIRT=1 $(PHPINC) -c -o libvirt-php.o libvirt-php.c $(LIBXML_CFLAGS) $(DEFINES)
$(CC) $(CFLAGS) -Wall -fpic -DCOMPILE_DL_LIBVIRT=1 -c -o vncfunc.o vncfunc.c $(PHPINC) $(LIBXML_CFLAGS) $(DEFINES)
$(CC) $(CFLAGS) -Wall -fpic -DCOMPILE_DL_LIBVIRT=1 -c -o sockets.o sockets.c $(PHPINC) $(LIBXML_CFLAGS) $(DEFINES)
$(CC) $(CFLAGS) -Wall -shared $(LIBS) -rdynamic -o $(PACKAGE).so vncfunc.o sockets.o libvirt-php.o -ldl -lvirt $(LIBXML_LIBS)
$(ECHO) "Extension compiled as $(PACKAGE).so"
install-exec-local:
......
......@@ -256,6 +256,11 @@ PHP_RINIT_FUNCTION(libvirt)
LIBVIRT_G(last_error) = NULL;
LIBVIRT_G(vnc_location) = NULL;
change_debug(0);
#if __BYTE_ORDER == __BIG_ENDIAN
_is_bigendian = 1;
#elif __BYTE_ORDER == __LITTLE_ENDIAN
_is_bigendian = 0;
#endif
return SUCCESS;
}
......@@ -2977,13 +2982,13 @@ PHP_FUNCTION(libvirt_domain_send_keys)
char *xml = NULL;
char *hostname = NULL;
int hostname_len;
char *keys = NULL;
unsigned char *keys = NULL;
int keys_len;
int ret = 0;
GET_DOMAIN_FROM_ARGS("rss",&zdomain, &hostname, &hostname_len, &keys, &keys_len);
DPRINTF("%s: Sending %d VNC keys to %s...\n", PHPFUNC, (int)strlen(keys), hostname);
DPRINTF("%s: Sending %d VNC keys to %s...\n", PHPFUNC, (int)strlen((const char *)keys), hostname);
xml=virDomainGetXMLDesc(domain->domain, 0);
if (xml==NULL) {
......@@ -2997,7 +3002,7 @@ PHP_FUNCTION(libvirt_domain_send_keys)
RETURN_FALSE;
}
DPRINTF("%s: About to send string '%s' (%d keys) to %s:%s\n", PHPFUNC, keys, (int)strlen(keys), hostname, tmp);
DPRINTF("%s: About to send string '%s' (%d keys) to %s:%s\n", PHPFUNC, keys, (int)strlen((const char *)keys), hostname, tmp);
ret = vnc_send_keys(hostname, tmp, keys);
DPRINTF("%s: Sequence sending result is %d\n", PHPFUNC, ret);
......@@ -3333,7 +3338,9 @@ PHP_FUNCTION(libvirt_domain_new)
if ((arch == NULL) || (arch_len == 0))
arch = NULL;
//DPRINTF("%s = { name: %s, arch: %s, memMB: %d, maxmemMB: %d, vcpus: %d, iso_image: %s }\n", PHPFUNC, name, arch, memMB, maxmemMB, vcpus, iso_image);
//DPRINTF("%s: name: %s, arch: %s, memMB: %d, maxmemMB: %d, vcpus: %d, iso_image: %s\n", PHPFUNC, name, arch, memMB, maxmemMB, vcpus, iso_image);
if (memMB == 0)
memMB = maxmemMB;
/* Parse all disks from array */
arr_hash = Z_ARRVAL_P(disks);
......@@ -3379,6 +3386,7 @@ PHP_FUNCTION(libvirt_domain_new)
numNets = i;
snprintf(tmpname, sizeof(tmpname), "%s-install", name);
DPRINTF("%s: Name is '%s', memMB is %d, maxmemMB is %d\n", PHPFUNC, tmpname, memMB, maxmemMB);
tmp = installation_get_xml(1,
conn->conn, tmpname, memMB, maxmemMB, NULL /* arch */, NULL, vcpus, iso_image,
vmDisks, numDisks, vmNetworks, numNets,
......@@ -3392,7 +3400,7 @@ PHP_FUNCTION(libvirt_domain_new)
domain = virDomainCreateXML(conn->conn, tmp, 0);
if (domain == NULL) {
set_error_if_unset("Cannot create installation domain from the XML description");
DPRINTF("%s: Cannot create installation domain from the XML description (%s)\n", PHPFUNC, LIBVIRT_G(last_error));
DPRINTF("%s: Cannot create installation domain from the XML description (%s): %s\n", PHPFUNC, LIBVIRT_G(last_error), tmp);
RETURN_FALSE;
}
......@@ -7362,7 +7370,7 @@ PHP_FUNCTION(libvirt_logfile_set)
RETURN_FALSE;
}
if ((filename == NULL) || (filename_len < 1) || (strcasecmp(filename, "null") == 0))
if ((filename == NULL) || (strcasecmp(filename, "null") == 0))
err = set_logfile(NULL, 0);
else
err = set_logfile(filename, maxsize);
......
......@@ -83,6 +83,14 @@ typedef uint64_t arch_uint;
#define UINTx PRIx64
#endif
int connect_socket(char *server, char *port, int keepalive, int nodelay, int allow_server_override);
int socket_has_data(int sfd, long maxtime, int ignoremsg);
void socket_read(int sfd, long length);
int _is_bigendian;
#define SWAP2_BY_ENDIAN(le, v1, v2) (((le && _is_bigendian) || (!le && !_is_bigendian)) ? ((v2 << 8) + v1) : ((v1 << 8) + v2))
typedef struct _resource_info {
int type;
virConnectPtr conn;
......
......@@ -115,7 +115,7 @@ int socket_has_data(int sfd, long maxtime, int ignoremsg)
{
fd_set fds;
struct timeval timeout;
int rc, result;
int rc;
timeout.tv_sec = maxtime / 1000000;
timeout.tv_usec = (maxtime % 1000000);
......
This diff is collapsed.
<?php
$logfile = 'test-install.log';
unlink($logfile);
libvirt_logfile_set($logfile, 10);
$name = 'test';
$image = '/tmp/test-libvirt-php.tmp';
$disk_image = '/tmp/test-libvirt-php.img';
$local_test = true;
$show_vnc_location = false;
$memory = 64;
......@@ -12,7 +17,7 @@
bail('Connection to default hypervisor failed');
$disks = array(
array( 'path' => '/tmp/test-libvirt-php.img', 'driver' => 'raw', 'bus' => 'ide', 'dev' => 'hda', 'size' => '1M',
array( 'path' => $disk_image, 'driver' => 'raw', 'bus' => 'ide', 'dev' => 'hda', 'size' => '1M',
'flags' => VIR_DOMAIN_DISK_FILE | VIR_DOMAIN_DISK_ACCESS_ALL )
);
......@@ -28,12 +33,15 @@
$flags |= VIR_DOMAIN_FLAG_TEST_LOCAL_VNC;
$res = libvirt_domain_new($conn, $name, false, $memory, $memory, 1, $image, $disks, $networks, $flags);
if ($res == false)
bail('Installation test failed with error: '.libvirt_get_last_error().'. More info saved into '.$logfile);
$ok = is_resource($res);
$vncloc = libvirt_domain_new_get_vnc();
if (!libvirt_domain_destroy($res))
bail('Domain destroy failed with error: '.libvirt_get_last_error());
bail('Domain destroy failed with error: '.libvirt_get_last_error().'. More info saved into '.$logfile);
unset($res);
......@@ -44,7 +52,8 @@
unset($res);
unset($conn);
@unlink('/tmp/test-libvirt-php.img');
@unlink($disk_image);
unlink($logfile);
if ($ok) {
if ($show_vnc_location)
......
......@@ -10,7 +10,7 @@
$bind_minor = $res['connector.minor'];
$bind_micro = $res['connector.release'];
unset($res);
if (libvirt_check_version($virt_major, $virt_minor, $virt_micro + 1, VIR_VERSION_LIBVIRT))
bail("Checking against release version currently installed libvirt version + 1 failed");
......@@ -23,7 +23,7 @@
if (!libvirt_check_version($bind_major, $bind_minor, $bind_micro, VIR_VERSION_BINDING))
bail("Checking against currently installed libvirt-php version failed");
if (libvirt_check_version($bind_major, $bind_minor, $bind_micro))
if (libvirt_check_version($bind_major, $bind_minor, $bind_micro, VIR_VERSION_BINDING))
success( basename(__FILE__) );
else bail("Bad parameters analyse");
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment